夥計們,我正面臨與Tab-host不同的問題,我會以清晰的步驟解釋。問題使用tab-host android?
1.我用6個選項卡顯示標籤主機。
2.在第六個選項卡上點擊,我顯示彈出窗口,其中包含Buttons.Until在這裏,每件事情都對我很好。
3.當彈出按鈕被點擊。我需要顯示另一個活動,但是標籤主機應該位於每個屏幕的底部?
用於顯示標籤主機&彈出我使用下面的代碼。
私人無效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());
}
請傢伙,我怎麼能做到這一點....
你準確的問題是什麼?問題是「標籤主機應該在每個屏幕底部」只? – 2012-02-17 06:36:22
是tabhost應該在每個屏幕的底部.. – 2012-02-17 06:38:56