【问题标题】:Customize TabHost's button behavior自定义 TabHost 的按钮行为
【发布时间】:2013-07-02 05:51:21
【问题描述】:

我目前正在开发具有tabbar 包含四个选项卡按钮的应用程序。选项卡按钮之一是“信息”选项卡。 The information tab shows the information dialog containing detail info regarding to the activity.

Required:信息标签的行为是动态的,它对不同的活动显示不同的信息细节。

有可能吗?如何做到这一点?或任何其他解决方案。

还有一点:Is it possible to show the tab bar for entire application?

提前致谢

【问题讨论】:

    标签: android tabs dialog android-tabhost


    【解决方案1】:

    看你的代码会是什么样子

    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;
        }
    });
    

    【讨论】:

      猜你喜欢
      • 2019-07-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多