HI all,
I need your help guys its very urgent.
I m developing one application and in my class i have 4 tabs and inside each tab i have list view. i want to display data into the list view. i m providing the data in the array but the problem is when my app starts it display the data of 4 tabs under single tab. bt when i click one by one on tabs den it shows the data correctly.
Here is the source code..:
public class test extends TabActivity implements OnTabChangeListener {
private static final String LIST_TAB_TAG = "News";
private static final String LIST_TAB_TAG2 = "List2";
private static final String LIST_TAB_TAG3 = "List3";
private static final String LIST_TAB_TAG4 = "List4";
private TabHost tabHost,tabHost1,tabHost2,tabHost3;
private ListView listView,listview2,listview3,listview4;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.clistview);
tabHost = (TabHost) findViewById(android.R.id.tabhost);
// setup must be called if you are not inflating the tabhost from XML
tabHost.setup();
tabHost.setOnTabChangedListener(this);
listView = (ListView) findViewById(R.id.list);
listview2 = (ListView) findViewById(R.id.list2);
listview3 = (ListView) findViewById(R.id.list3);
listview4 = (ListView) findViewById(R.id.list4);
// create some dummy coordinates to add to the list
List<String> list1Strings = new ArrayList<String>();
list1Strings.add("");
list1Strings.add("Item 2");
list1Strings.add("Item 3");
list1Strings.add("Item 4");
listView.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, list1Strings));
List<GeoPoint> pointsList2 = new ArrayList<GeoPoint>();
pointsList2.add(new GeoPoint((int)(464464645), (int)(979646664)));
pointsList2.add(new GeoPoint((int)(7976566), (int)(987464313)));
listview2.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, pointsList2));
List<GeoPoint> pointsList3 = new ArrayList<GeoPoint>();
pointsList3.add(new GeoPoint((int)(32.864*1E6), (int)(-117.2353*1E6)));
pointsList3.add(new GeoPoint((int)(37.441*1E6), (int)(-122.1419*1E6)));
listview3.setAdapter(new ArrayAdapter(this,android.R.layout.simple_list_item_1, pointsList3));
List<GeoPoint> pointsList4 = new ArrayList<GeoPoint>();
pointsList4.add(new GeoPoint((int)(464464645), (int)(979646664)));
pointsList4.add(new GeoPoint((int)(7976566), (int)(987464313)));
listview4.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, pointsList4));
tabHost.addTab(tabHost.newTabSpec(LIST_TAB_TAG).setIndicator("News", getResources().getDrawable(R.drawable.newsicon)).setContent(new TabContentFactory()
{
public View createTabContent(String arg0) {
return listView;
}
}));
tabHost.addTab(tabHost.newTabSpec(LIST_TAB_TAG2).setIndicator("Opinion", getResources().getDrawable(R.drawable.opinionicon)).setContent(new TabContentFactory() {
public View createTabContent(String arg0) {
return listview2;
}
}));
tabHost.addTab(tabHost.newTabSpec(LIST_TAB_TAG3).setIndicator("Press", getResources().getDrawable(R.drawable.pressicon)).setContent(new TabContentFactory() {
public View createTabContent(String arg0) {
return listview3;
}
}));
tabHost.addTab(tabHost.newTabSpec(LIST_TAB_TAG4).setIndicator("My Stocks", getResources().getDrawable(R.drawable.mystockicon)).setContent(new TabContentFactory() {
public View createTabContent(String arg0) {
return listview4;
}
}));
//HACK to get the list view to show up first,
//tabHost.setCurrentTab(1);
//tabHost.setCurrentTab(0);
}
@Override
/*protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}*/
public void onTabChanged(String tabId) {
// TODO Auto-generated method stub
}
}
can u pls help me guys asap. thanks in advance.