如何显示 toast 消息 bt 我存储的选项卡标题的名称是滑动或触摸选项卡上的数组
how to show toast message bt the name of my tab titles stored is array on swipe or tab touched
how to show toast message for tab tiles, public String[] tab_titles = {"Sun","Mon","Tue","Wed","Thur","Fri","Sat"}; when on the individual tab
我不确定您能否获得标签 name.but 您可能会获得 TabSpec 名称。
试试下面的代码希望它能帮到你。
TabHost tabHost;
tabHost = (TabHost) rootView.findViewById(R.id.tab_host);
tabHost.setup();
tabHost.addTab(tabHost.newTabSpec("Tabspec1").setIndicator("Academics").setContent(R.id.academicslistview));
tabHost.addTab(tabHost.newTabSpec("Tabspec2").setIndicator("Extracurricular").setContent(R.id.extracurricularlistview));
tabHost.setCurrentTab(0);
tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
@Override
public void onTabChanged(String tabId) {
// TODO Auto-generated method stub
int selectedTab = tabHost.getCurrentTab();
Log.d("Tab", "count" + selectedTab);
Toast.makeText(getApplicationContext(), "Tab Title" + mTabHost.getCurrentTab(), Toast.LENGTH_LONG).show();
}
});
how to show toast message for tab tiles, public String[] tab_titles = {"Sun","Mon","Tue","Wed","Thur","Fri","Sat"}; when on the individual tab
我不确定您能否获得标签 name.but 您可能会获得 TabSpec 名称。 试试下面的代码希望它能帮到你。
TabHost tabHost;
tabHost = (TabHost) rootView.findViewById(R.id.tab_host);
tabHost.setup();
tabHost.addTab(tabHost.newTabSpec("Tabspec1").setIndicator("Academics").setContent(R.id.academicslistview));
tabHost.addTab(tabHost.newTabSpec("Tabspec2").setIndicator("Extracurricular").setContent(R.id.extracurricularlistview));
tabHost.setCurrentTab(0);
tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
@Override
public void onTabChanged(String tabId) {
// TODO Auto-generated method stub
int selectedTab = tabHost.getCurrentTab();
Log.d("Tab", "count" + selectedTab);
Toast.makeText(getApplicationContext(), "Tab Title" + mTabHost.getCurrentTab(), Toast.LENGTH_LONG).show();
}
});