2012-02-17 80 views
1

夥計們,我正面臨與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()); 


} 

請傢伙,我怎麼能做到這一點....

+0

你準確的問題是什麼?問題是「標籤主機應該在每個屏幕底部」只? – 2012-02-17 06:36:22

+0

是tabhost應該在每個屏幕的底部.. – 2012-02-17 06:38:56

回答

0

這多少有點像您從選項卡中單擊呼叫的第一項活動。那第一個活動有彈出窗口。現在點擊彈出窗口的按鈕,您正在調用第二個活動? 是否正確,那麼你必須擁有該關鍵標籤中的所有活動。併爲此按照此鏈接:THIS LINK

+0

sry這我已經在我的代碼中做了...我的要求是不是這個,點擊tabwidget我將彈出顯示,其中包含buttons.when我將點擊按鈕,我需要去新的活動,但tabhost應保持相同.... – 2012-02-17 06:58:16

+0

看到更新的答案。 – 2012-02-17 07:04:03

+0

sry ....我會更清楚地解釋你,Think First的活動是tabhost.it由6個選項卡組成,當我點擊第六個選項卡時,我將顯示popwindow。其中包括按鈕,當我點擊彈出窗口中的第一個按鈕時,應該啓動新的活動...由tabhost應該保持相同。在第六個按鈕,我使用下面的代碼點擊.. – 2012-02-17 07:25:32

0

對於我的應用程序,我已經有這個問題。在我的應用程序中,我的列表視圖包含一些項目。當我按任何一個項目時都會顯示詳細視圖到另一個佈局。而且,我已經使用這個代碼來做到這一點 -

ListView list = (ListView)findViewById(R.id.listview12); 
     list.setAdapter(adapter); 

     list.setOnItemClickListener(new OnItemClickListener() 
     { 
      @SuppressWarnings("unchecked") 
      public void onItemClick(AdapterView<?> parent, View view, int position, long id) 
      { 
       HashMap<String, String> hashMap = new HashMap<String, String>(); 
       hashMap = (HashMap<String, String>) parent.getItemAtPosition(position); 
       String newsid = hashMap.get("id"); 
       int integerid = Integer.parseInt(newsid); 
       description(integerid); 

       //Get the new Activity to tab. 
       Intent previewMessage = new Intent(getParent(), detailedview.class); 
       TabGroupActivity parentActivity = (TabGroupActivity)getParent(); 
       parentActivity.startChildActivity("detailedview", previewMessage); 
      } 
     }); 

我只要按照這些代碼,並通過做我的問題出這個Multiple Android Activities in a TabActivity。它提供了Parent & Child方法。它對我非常有用。而且,它對你也很有用。試試吧......!希望這可以幫助你.. :-)