Android 在操作栏中滑动选项卡
我正在使用顶部的滑动选项卡 我想把账单放在底部。我该怎么做? 这是我的标签代码: XML文件:Android 在操作栏中滑动选项卡,android,android-actionbar,android-tabs,Android,Android Actionbar,Android Tabs,我正在使用顶部的滑动选项卡 我想把账单放在底部。我该怎么做? 这是我的标签代码: XML文件: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" androi
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ProductDetails" >
<fragment
android:id="@+id/fragmentTopFragment"
android:name="com.lenovo.bsharp.ProductDetailsTopFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</android.support.v4.view.ViewPager>
<!-- <android.support.v4.view.PagerTitleStrip
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id = "@+id/title"
android:layout_gravity="top"
android:paddingTop="4dp"
android:paddingBottom="4dp">
</android.support.v4.view.PagerTitleStrip> -->
</RelativeLayout>
</LinearLayout>
我还想做一个适当的边界,因为你可以看到,在中间的边界是不正确的。星号下方。您只需为底部栏选项卡实现TabFragmentHost,也可在此中使用。发布一个快照以更好地理解。@MD请查看。@MD还希望使右侧与图像相等。我已使用FragmentTabHost实现底部选项卡片段。GitHub上的代码:@MD正如我在上面写的那样,我是通过操作栏来完成的,所以我应该在上面的代码中更改哪些内容。如何在GridView中设置numColumns?在xml中,可以设置列数,也可以将其设置为aut
viewPager = (ViewPager) findViewById(R.id.pager);
FragmentManager fragmentManager = getSupportFragmentManager();
viewPager.setAdapter(new MyAdapter(fragmentManager));
viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
actionBar.setSelectedNavigationItem(position);
}
@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
}
@Override
public void onPageScrollStateChanged(int arg0) {
}
});
actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
ActionBar.Tab tab1 = actionBar.newTab();
tab1.setText("Description");
tab1.setTabListener(this);
ActionBar.Tab tab2 = actionBar.newTab();
tab2.setText("Tech Spec");
tab2.setTabListener(this);
ActionBar.Tab tab3 = actionBar.newTab();
tab3.setText("Features");
tab3.setTabListener(this);
actionBar.addTab(tab1);
actionBar.addTab(tab2);
actionBar.addTab(tab3);
}
public class MyAdapter extends FragmentPagerAdapter {
public MyAdapter(android.support.v4.app.FragmentManager fm) {
super(fm);
// TODO Auto-generated constructor stub
}
@Override
public Fragment getItem(int pageNo) {
Fragment fragment = null;
if (pageNo == 0) {
fragment = new ProductDetailsLeftFragment();
}
if (pageNo == 1) {
fragment = new ProductDetailsRightFragment();
}
if (pageNo == 2) {
fragment = new ProductDetailsPagerThirdFragment();
}
return fragment;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return 3;
}
/*
* @Override public CharSequence getPageTitle(int position) { if
* (position == 0) { return "Description"; } else if (position == 1) {
* return "Tech Spec"; } else if (position == 2) { return "Features"; }
* return null; }
*/
}