2013-07-02 40 views
1

我目前正在使用包含四個選項卡按鈕的tabbar的應用程序。其中一個選項卡按鈕是「信息」選項卡。 The information tab shows the information dialog containing detail info regarding to the activity.自定義TabHost的按鈕行爲

Required:信息標籤的行爲是動態的,它顯示了不同的信息細節,以不同的活動。

可能嗎?如何實現這一目標?或任何其他解決方案。

還有一點:Is it possible to show the tab bar for entire application?

在此先感謝

回答

0

看到你的代碼會像

TabHost tabHost = getTabHost(); 
    // Tab for Photos 
TabSpec photospec = tabHost.newTabSpec("Photos"); 
    // setting Title and Icon for the Tab 
    photospec.setIndicator("Photos", getResources().getDrawable(R.drawable.icon_photos_tab)); 
    Intent photosIntent = new Intent(this, PhotosActivity.class); 
    photospec.setContent(photosIntent); 


    // Adding all TabSpec to TabHost 
    tabHost.addTab(photospec); // Adding photos tab 
    tabHost.addTab(songspec); // Adding songs tab 
    tabHost.addTab(videospec); // Adding videos tab 

你需要處理的標籤的事件如下

tabHost.getChildAt(1).setOnTouchListener(new OnTouchListener() { 

    @Override 
    public boolean onTouch(View v, MotionEvent event) { 
     int action = event.getAction(); 

     if(action == MotionEvent.ACTION_UP) 
     { 
      //Something to do 

      return true; // do this if you dont want the tab to change 
     } 
     return false; 
    } 
});