安卓tabwidget需要帮助 [英] android tabwidget need help

查看:224
本文介绍了安卓tabwidget需要帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我创建一个应用程序
我已经创建了从pressing第一个选项卡我下载的文件,并进入第二个选项卡将列出使用AsyncTask的所有下载files..i我下载文件的TabBar ..
 我想要做的是,pressing的按钮下载文件我想显示第二个选项卡中打开,它是所有下载的文件列表它怎么可能后?这是我的testclass.java,它扩展了 TabActivity

hello i am creating an application i've created tabbar from pressing the first tab i am downloading a file and into second tab it lists all the downloaded files..i am downloading file using the asyncTask.. i want to do is,after pressing the button for the downloading file i want to show 2nd tab open that is the list of the all downloaded files how it can be possible ? this is my testclass.java that extends the TabActivity

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.maiin);
        final TabHost tabHost = (TabHost) getTabHost();
        tabHost.addTab(createTab(activity1name.class, "Welcome",
                "Welcome", R.drawable.tab_icon_events));
        tabHost.addTab(createTab(activity2name.class, ".Mp3List", ".Mp3List",
                R.drawable.tab_icon_pitchforkfm));
        tabHost.addTab(createTab(AboutUs.class, "AboutUs", "AboutUs",
                R.drawable.tab_icon_home));
        tabHost.addTab(createTab(ExtraInfromation.class, "Extra", "Extra",
                R.drawable.tab_icon_tv));
        tabHost.setCurrentTab(0);
        tabHost.getTabWidget().getChildAt(0).getLayoutParams().width = 85;
        tabHost.getTabWidget().getChildAt(1).getLayoutParams().width = 85;
        tabHost.getTabWidget().getChildAt(2).getLayoutParams().width = 85;
        tabHost.getTabWidget().getChildAt(3).getLayoutParams().width = 85;
    }
    private TabSpec createTab(final Class<?> intentClass, final String tag,
            final String title, final int drawable) {
        final Intent intent = new Intent().setClass(this, intentClass);

        final View tab = LayoutInflater.from(getTabHost().getContext())
                .inflate(R.layout.tab, null);
        ((TextView) tab.findViewById(R.id.tab_text)).setText(title);
        ((ImageView) tab.findViewById(R.id.tab_icon))
                .setImageResource(drawable);
        return getTabHost().newTabSpec(tag).setIndicator(tab)
                .setContent(intent);
    }
}

在此先感谢..:Pragna

thanks in advance..:Pragna

推荐答案

如果您想从一个选项卡中切换到另一个选项卡,你可以利用这一点,

If you want to switch to another tab from within a Tab, you can use this,

在您MainActivity延伸一个tabActivity,指定这样的方法,

In your MainActivity which extends a tabActivity, specify a method like this,

  public void switchTabSpecial(int tab){
    tabHost.setCurrentTab(tab);
  }

在你的下载按钮的onclick监听器,

Inside the onClick listener of your download button,

 mainAcitivity t=(mainActivity)this.getParent();
       t.switchTabSpecial(1);

现在这个会遍历你从你的第一个标签到第二个选项卡。

Now this will traverse you from your first tab to second tab.

这篇关于安卓tabwidget需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆