关于ActionBar Tab与ListFragment的结合
来源:互联网 发布:百度彩票数据接口 编辑:程序博客网 时间:2024/04/30 02:50
<FrameLayout android:id="@+id/main_titles" android:layout_width="0px" android:layout_height="match_parent" android:layout_weight="1" />Actionbar继承Activity即可
通过复写onTabSelected方法可使每个Tab对应到相应的fragment
</pre><pre name="code" class="java">public void onTabSelected(Tab tab, FragmentTransaction ft) {ft.replace(R.id.main_titles, fragment, null); }//用相应的Fragment填充FrameLayout
Fragment.java继承ListFragment来实现列表效果,通过复写oncreatview将listview填充进上述FrameLayout中
@Overridepublic View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) { return inflater.inflate(R.layout.fragment_list, container,false);}
下面是fragment_list.xml的代码,一定要有Listview,一定要有<span style="font-family: Arial, Helvetica, sans-serif;">android:id="@id/android:list"</span>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <!-- listfragment 一定要从android:list中启动 --> <ListView android:id="@id/android:list" android:layout_width="match_parent" android:layout_height="match_parent" /></LinearLayout>在public void onActivityCreated(Bundle savedInstanceState)中设置listadapter
setListAdapter(simpleAdapter);
各种adapter,如simpleadapter,arrayadapter,等等都可以放入setListAdapter,
这样就可以实现actionbar Tab中放入listFragment的效果了!
0 0
- 关于ActionBar Tab与ListFragment的结合
- 关于actionbar和popupmenu结合的实例
- Fragment与ActionBar的结合使用
- 简单DrawerLayout与ActionBar的结合使用
- ActionBar结合Fragment实现Tab导航
- ActionBar结合Fragment实现Tab导航
- ActionBar的Tab模式
- ActionBar详解(五)--->利用ActionBar结合Fragment实现Tab导航
- ActionBar Tab与ViewPager整合
- ActionBar与ViewPager结合使用
- ActionBar之Tab的使用
- ActionBar的Tab导航用法
- Android ActionBar Tab的宽度
- 关于ListFragment的基本写法及注意事项
- ActionBar结合Fragment实现Tab导航、下拉式导航
- 开源PagerSlidingTabStrip的使用Tab与ViewPager的完美结合
- 顶部tab的实现,与viewpager结合使用的例子
- ActionBar Tab
- 第五章 用到的准备数据
- python问题笔记
- 自动轮播的ViewPage(开源项目)
- qt学习3——vs版qt出现的问题
- Zookeeper源码编译为Eclipse工程(win7下Ant编译)
- 关于ActionBar Tab与ListFragment的结合
- ios8来了,屏幕更大,准备好使用 iOS Auto Layout了吗?
- EasyConnect
- 关于IOS8的Autolayout特性的理解以及使用
- Java的内部类(Inner Class)和嵌套类(Nested Class)的区别
- poj1149 PIGS DINIC
- Python 爬虫网页抓图保存
- POJ 2373 (Dividing the Path)单调队列优化DP
- SSH框架搭建