SherlockFragment On Load里面的Listview。布局不膨胀

时间:2013-05-04 16:41:18

标签: android android-listview actionbarsherlock

以下是我的示例设置

Splashscreen - >指向主动 - > 2个标签(Tab1,Tab2) 我需要在Tab1中夸大列表视图。

Listview

这是我的代码。

从启动画面(工作正常

protected void onPostExecute(Void result) {
        // TODO Auto-generated method stub
        Intent i = new Intent(SplashScreen.this, MainActivity.class);
        startActivity(i);
    }

MainActivity.java(工作正常 - 在顶部加载2个标签

public class MainActivity extends SherlockFragmentActivity {
public static String ACTIVE_TAB = "activeTab";  

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.categories_list);
AppRater.displayAsk2Rate(this, 7, 1, false);

getSupportActionBar().setTitle("Keto Recipes");
getSupportActionBar().setSubtitle("ketozen.com");

final ActionBar actionBar = getSupportActionBar();  
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);  
// add tabs  
Tab tab1 = actionBar  
              .newTab()  
              .setText("Art")  
              .setTabListener(  
                        new TabListener<TabFragment>(this, "tab1",  
                                  TabFragment.class));  
actionBar.addTab(tab1);  
Tab tab2 = actionBar  
              .newTab()  
              .setText("Science")  
              .setTabListener(  
                        new TabListener<TabFragment1>(this, "tab2",  
                                  TabFragment1.class));  
actionBar.addTab(tab2);  
// check if there is a saved state to select active tab  
if (savedInstanceState != null) {  
    getSupportActionBar().setSelectedNavigationItem(  
             savedInstanceState.getInt(ACTIVE_TAB));  

}
}

TabFragment.Java( LISTVIEW应加载的第一个标签。不工作

public class TabFragment extends SherlockFragment {  
@Override  
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {  
// Inflate the layout for this fragment  
View view = inflater.inflate(R.layout.categories_list, container, false);  
               // do your view initialization here  
return view;  
 }  

}

这是我的categories_list XML

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/lytContent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/background">

<com.google.ads.AdView
xmlns:googleads="http://schemas.android.com/apk/lib/com.google.ads"
    android:id="@+id/ads"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@color/background"
    googleads:adSize="SMART_BANNER"
    googleads:adUnitId="@string/admob_id"
    android:layout_alignParentBottom="true" />

<ListView
    android:id="@+id/listCategories"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/ads"
    android:layout_below="@+id/lytTitleBar"
    android:divider="@color/separator"
    android:dividerHeight="1dp"
    android:fadeScrollbars="true"
    android:fadingEdge="none"
    android:fastScrollEnabled="true" />

<TextView 
    android:id="@+id/txtAlert"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/alert"
    android:textColor="@color/text"
    android:textSize="14sp"
    android:layout_centerInParent="true"
    android:visibility="gone"/>

请任何想法。

1 个答案:

答案 0 :(得分:0)