如何使用活动制作可滑动的标签?

时间:2017-11-29 12:34:09

标签: java android android-activity tabs android-tabhost

我尝试创建一个Android Feed应用程序,它有不同的标签,我使用tab-host和不同的活动做到了,所以它现在有效,但我想让它成为swipe_able,请帮助我! ! (如何在不使用片段的情况下进行滑动) (如何用活动做这个)`         tabHost =(TabHost)findViewById(android.R.id.tabhost);

    TabHost.TabSpec activity1 = tabHost.newTabSpec("Latest");
    activity1.setIndicator("Latest",getResources().getDrawable(R.mipmap.ic_launcher));
    Intent phoneStatusIntent = new Intent(this, Home.class);
    activity1.setContent(phoneStatusIntent);

    TabHost.TabSpec activity2 = tabHost.newTabSpec("Trending");
    activity2.setIndicator("Trending",getResources().getDrawable(R.mipmap.ic_launcher));
    Intent trendIntent = new Intent(this, Trend.class);
    activity2.setContent(trendIntent);

    TabHost.TabSpec activity3 = tabHost.newTabSpec("NewPic");
    activity3.setIndicator("New Pic",getResources().getDrawable(R.mipmap.ic_launcher));
    Intent batteryIntent = new Intent(this, NewPic.class);
    activity3.setContent(batteryIntent);



    // Adding all TabSpec to TabHost
    tabHost.addTab(activity1);
    tabHost.addTab(activity2);
    tabHost.addTab(activity3);`

0 个答案:

没有答案