tab-host android 有问题吗?
伙计们,我在 Tab-host 方面面临着不同的问题,我将清楚地解释步骤。
1.我正在显示带有 6 个选项卡的选项卡主机。
2.单击第六个选项卡时,我将显示弹出窗口,其中包含按钮。直到这里一切对我来说都工作正常。
3.当在弹出窗口中单击按钮时。我需要显示另一个活动,但选项卡主机应该位于每个屏幕的底部?
为了显示选项卡主机和弹出窗口,我使用以下代码。
private void setuptabs() {
// Adding the tabs to TabHost.
addTab("Balances", R.drawable.tab_search, BalancesActivity.class);
addTab("Orders", R.drawable.tab_search, OrdersActivity.class);
addTab("positions", R.drawable.tab_search, PositionsActivity.class);
addTab("Trade", R.drawable.tab_search, TradeActivity.class);
addTab("WatchList", R.drawable.tab_search, WatchlistActivity.class);
addTab("Chains", R.drawable.tab_search, ChainsActivity.class);
addTab("More", R.drawable.tab_search, MoreActivity.class);
tabHost.getTabWidget().getChildAt(6).setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
QuickActionView qa = QuickActionView.Builder(v);
// set the adapter
qa.setAdapter(new CustomAdapter(getApplicationContext()));
// set the number of columns ( setting -1 for auto )
qa.setNumColumns(1);
qa.setOnClickListener(new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
Toast.makeText(getBaseContext(), "Selected item: " + which,Toast.LENGTH_SHORT).show();
switch (which) {
case 0:
break;
case 1:
break;
default:
break;
}
}
});
// finally show the view
qa.show();
return false;
}
});
}
private void addTab(String labelId, int drawableId, Class<?> c) {
tabHost = getTabHost();
intent = new Intent(this, c);
spec = tabHost.newTabSpec("tab" + labelId);
View tabIndicator = LayoutInflater.from(this).inflate(R.layout.tab_indicator, getTabWidget(), false);
// txtTitle will set the title in TabHost.
txtTitle = (TextView) tabIndicator.findViewById(R.id.txtTitles);
txtTitle.setText(labelId);
// imgTab will set the image in TabHost.
imgTab = (ImageView) tabIndicator.findViewById(R.id.imgTab);
imgTab.setImageResource(drawableId);
spec.setIndicator(tabIndicator);
spec.setContent(intent);
tabHost.addTab(spec);
// tabHost.getTabWidget().getChildAt(7).setVisibility(View.GONE);
System.out.println("Checking tabhost value::>"+tabHost.getChildCount());
}
拜托各位,我怎样才能做到这一点......
Guys i am facing a different problem with Tab-host,I will explain with steps clearly.
1.I am displaying the tab-host with 6 tabs.
2.On Click of the sixth tab, i am displaying the popup, which consists of Buttons.Until here every thing is working fine to me.
3.When button is clicked in popup. I need to display the another activity,but tab-host should be at bottom for every screen?
for displaying the tab-host&popup i am using the following code.
private void setuptabs() {
// Adding the tabs to TabHost.
addTab("Balances", R.drawable.tab_search, BalancesActivity.class);
addTab("Orders", R.drawable.tab_search, OrdersActivity.class);
addTab("positions", R.drawable.tab_search, PositionsActivity.class);
addTab("Trade", R.drawable.tab_search, TradeActivity.class);
addTab("WatchList", R.drawable.tab_search, WatchlistActivity.class);
addTab("Chains", R.drawable.tab_search, ChainsActivity.class);
addTab("More", R.drawable.tab_search, MoreActivity.class);
tabHost.getTabWidget().getChildAt(6).setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
QuickActionView qa = QuickActionView.Builder(v);
// set the adapter
qa.setAdapter(new CustomAdapter(getApplicationContext()));
// set the number of columns ( setting -1 for auto )
qa.setNumColumns(1);
qa.setOnClickListener(new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
Toast.makeText(getBaseContext(), "Selected item: " + which,Toast.LENGTH_SHORT).show();
switch (which) {
case 0:
break;
case 1:
break;
default:
break;
}
}
});
// finally show the view
qa.show();
return false;
}
});
}
private void addTab(String labelId, int drawableId, Class<?> c) {
tabHost = getTabHost();
intent = new Intent(this, c);
spec = tabHost.newTabSpec("tab" + labelId);
View tabIndicator = LayoutInflater.from(this).inflate(R.layout.tab_indicator, getTabWidget(), false);
// txtTitle will set the title in TabHost.
txtTitle = (TextView) tabIndicator.findViewById(R.id.txtTitles);
txtTitle.setText(labelId);
// imgTab will set the image in TabHost.
imgTab = (ImageView) tabIndicator.findViewById(R.id.imgTab);
imgTab.setImageResource(drawableId);
spec.setIndicator(tabIndicator);
spec.setContent(intent);
tabHost.addTab(spec);
// tabHost.getTabWidget().getChildAt(7).setVisibility(View.GONE);
System.out.println("Checking tabhost value::>"+tabHost.getChildCount());
}
Please guys,How i can achieve this....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这就像您通过选项卡单击调用第一个活动一样。第一个活动有弹出窗口。现在,单击弹出窗口的按钮,您可以调用第二个活动了???
那么您是否必须在该特定选项卡中进行所有活动。为此,请点击以下链接:此链接
It is something like you are calling first activity from tab click. that first activity have popup window. Now with click on button of popup window you are calling the Second Activity right ???
Is it right then you have to have that all activity in that perticular tab. and for that follow this link: THIS LINK
对于我的应用程序,我已经遇到了这个问题。在我的应用程序中,我的列表视图包含一些项目。当我按任何项目时,将显示另一个布局的详细视图。而且,我已经使用此代码来做到这一点 -
我只需遵循这些代码并通过此解决我的问题 一个 TabActivity 中的多个 Android Activity。它提供了
Parent
&子
方法。它对我来说非常有用。而且,它对你也非常有用。试试吧...!希望这对你有帮助..:-)For my application i'm already having this problem. In my application i've listview contains some items. When, i press anyone of the item will be displayed with detailed view to an another layout. And, i've use this code to do that -
I just follow these code and done my issues through out this Multiple Android Activities in a TabActivity. It provides
Parent
&Child
method. Its very useful for me. And, it'll very useful to you also. Just try it out...! Hope this helps you.. :-)