开发者

how to include expandable list view under single tab button

I am new to android and developing an application for shopping. I have just made two tab buttons now i want dependent dropdown list like country,state and city. Update: i have created two tabs , i want my application to work like this" when i click on first tab开发者_开发问答 it should display a dropdown list and on the click of item in that list , it should also display a list which should also contain items in it".that is i want a dependent list.

Any help will be appreciated thanks deep


You can specify the id of the content of your tabs with the setContent(view_id) as done here:

TabHost tabHost = getTabHost();
tabHost.addTab(
    tabHost
        .newTabSpec("tab_1")
        .setIndicator("tab 1", getResources().getDrawable(android.R.drawable.ic_menu_view))
        .setContent(R.id.list_view_1)
    );

In the example above, i'm specifying the id of a listview that i want to show for the first tab. Do this for all your tab/views.

You can also react on tab changes by adding listeners like this:

tabHost.setOnTabChangedListener(new OnTabChangeListener() {
    public void onTabChanged(String tabId) {
        if ("tab_1".equals(tabId)) {
            // ... user clicked tab_1, fill in the data in the view of the tab now
        }
    }
};
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜