I have a TabActivity with two tabs. the layout of the action is as follows:
<?xml version="1.0" encoding="utf-8"?> <TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5dp"> <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5dp"> <ListView android:id="@+id/list" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </FrameLayout> </LinearLayout> </TabHost>
The layout consists of a ListView, which is populated accordingly in setOnTabChangedListener (). no problems filling out the list and displaying it.
My problem is that the list view is not displayed when the action starts, although I find it by identifier and populate it; it is filled only after changing tabs.
and the code in onCreate (..) looks like this:
l = (ListView) findViewById(R.id.list); l.setAdapter(new CommentsAdapter(this, (JSONArray) obj)); TabSpec spec; spec = tabHost.newTabSpec("0").setIndicator("0", res.getDrawable(R.drawable.tab_recent)).setContent( R.id.list); tabHost.addTab(spec); spec = tabHost.newTabSpec("1").setIndicator("1", res.getDrawable(R.drawable.tab_pop)).setContent( R.id.list); tabHost.addTab(spec); tabHost.setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(String tabId) {
any clues?
source share