2013-05-04 1 views
0

Вот моя установка образцаListview внутри Шерлок Фрагмент при загрузке. Макет не надувать

SplashScreen -> Очки для Mainactivity -> 2 вкладки (Tab1, Таб2) мне нужно надуть ListView в Tab1.

Listview

Вот мои коды.

С SplashScreen (Works Ok)

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

MainActivity.java (Работы OK - Грузы до 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 (1 в которую должен загружаться 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"/> 

Любые идеи, пожалуйста.

ответ

Смежные вопросы