Android:如何填写SwipeyTabs?

Android:如何填写SwipeyTabs?,第1张

概述我在我的应用程序中使用SwipeyTabs.我不确定如何填写标签内容.它甚至没有任何自己的xml. 我正在使用这样的标签: @Overridepublic void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_s 我在我的应用程序中使用SwipeyTabs.我不确定如何填写标签内容.它甚至没有任何自己的xml.

我正在使用这样的标签:

@OverrIDepublic voID onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentVIEw(R.layout.activity_swipey_tabs);    initVIEwPager(4,0xFFFFFFFF,0xFF000000);    mSwipeyTabs = (SwipeyTabsVIEw) findVIEwByID(R.ID.swipey_tabs);    mSwipeyTabsAdapter = new SwipeyTabsAdapter(this);    mSwipeyTabs.setAdapter(mSwipeyTabsAdapter);    mSwipeyTabs.setVIEwPager(mPager);}private voID initVIEwPager(int pageCount,int backgroundcolor,int textcolor) {    mPager = (VIEwPager) findVIEwByID(R.ID.pager);    mPagerAdapter = new ExamplePagerAdapter(this,pageCount,backgroundcolor,textcolor);    mPager.setAdapter(mPagerAdapter);    mPager.setCurrentItem(1);    mPager.setPagemargin(1);}

这里是activity_swipey_tabs.xml布局:

<androID.ex.com.vIEwpager.extension.SwipeyTabsVIEw    androID:ID="@+ID/swipey_tabs"    androID:layout_wIDth="fill_parent"    androID:layout_height="wrap_content"    androID:background="#3B3B3B" /><VIEw    androID:ID="@+ID/colorline"    androID:layout_wIDth="fill_parent"    androID:layout_height="2dip"    androID:layout_below="@+ID/swipey_tabs"    androID:background="#FF91A438" /><VIEw    androID:ID="@+ID/blackline"    androID:layout_wIDth="fill_parent"    androID:layout_height="1dip"    androID:layout_below="@+ID/colorline"    androID:background="#FF000000" /><androID.support.v4.vIEw.VIEwPager    androID:ID="@+ID/pager"    androID:layout_wIDth="fill_parent"    androID:layout_height="fill_parent"    androID:layout_below="@+ID/blackline" />

有没有例子或教程?

任何支持都会很棒.

解决方法 SwipeyTabs的标签就像虚拟布局,我的意思是他们没有自己定义的布局.您应该动态定义每个组件.

让我详细解释一下.例如,您需要一个ListVIEw(自定义).你创建了这样的布局:

<relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"    androID:layout_wIDth="fill_parent"    androID:layout_height="70dp"    androID:padding="5dp"    androID:background="#ffffff" >    <ImageVIEw        androID:ID="@+ID/imageVIEw1"        androID:layout_wIDth="80dp"        androID:layout_height="60dp"        androID:layout_alignParentleft="true"        androID:layout_centerVertical="true"        androID:src="@drawable/i1" />    <TextVIEw        androID:ID="@+ID/textVIEw2"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:layout_alignBottom="@+ID/imageVIEw1"        androID:layout_alignParentRight="true"        androID:textcolor="@androID:color/black"        androID:textAppearance="?androID:attr/textAppearanceLarge" />    <TextVIEw        androID:ID="@+ID/textVIEw1"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:layout_alignRight="@+ID/textVIEw2"        androID:layout_aligntop="@+ID/imageVIEw1"        androID:textcolor="@androID:color/black" />    <TextVIEw        androID:ID="@+ID/textVIEw3"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:layout_alignBottom="@+ID/imageVIEw1"        androID:layout_toRightOf="@+ID/imageVIEw1"        androID:textcolor="@androID:color/black"        androID:textAppearance="?androID:attr/textAppearanceSmall" /></relativeLayout>

现在你需要一个ArrayAdapter来调整这个自定义ListVIEw,我不包括ArrayAdapter.

因此,在PagerAdapter类中,定义ListVIEw并使用此布局.例如:

@OverrIDepublic Object instantiateItem(VIEw container,int position) {    ListVIEw v = new ListVIEw( mContext );    //test_List_layout which is above    TestAdapter adapter = new TestAdapter(mContext,R.layout.test_List_layout,obJs);    v.setAdapter( adapter );    ((VIEwPager)container ).addVIEw( v,0 );    v.setSelection( scrollposition[ position ] );    v.setonScrollListener( new OnScrollListener() {                      public voID onScrollStateChanged( AbsListVIEw vIEw,int scrollState ){}         public voID onScroll( AbsListVIEw vIEw,int firstVisibleItem,int visibleItemCount,int totalitemCount ) {        scrollposition[ pos ] = firstVisibleItem;         }    });    return v;}

现在它运作良好.如果您需要更多选项卡,请使用position参数作为分隔符,如if(position == 0).在这里你需要这一行:

((VIEwPager) container).removeVIEw((VIEw) container);

就这样.我希望,很清楚.

总结

以上是内存溢出为你收集整理的Android:如何填写SwipeyTabs?全部内容,希望文章能够帮你解决Android:如何填写SwipeyTabs?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1135835.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存