新浪微博布局学习——妙用TabHost 分类: Android 2012-04-12 14:55 1921人阅读 评论(0) 收藏 举报
新浪微博androidradiobuttonlayoutbuttonsearch 前言 为了更好的开发Android应用程序,除了熟练掌握基本的UI组件和API外,还需要掌握一些技巧,而这些技巧可以通过阅读一些代码来提高,本系列将与大家分享一些新浪微博布局方面的收获,欢迎交流! 转载, 博客园:http://www.cnblogs.com 农民伯伯: http://www.cnblogs.com/over140 版本 新浪微博 weibo_10235010.apk 正文 一、效果图
红色部分是本文要实现的目标。
二、实现 maintabs.xml [html] view plaincopyprint?
1.
2. ndroid:layout_height=\ 3. xmlns:android=\> 4. t\ android:layout_height=\> 5. \ android:layout_height=\ android:layout_weight=\ /> 6. d:layout_width=\ android:layout_height=\ android:layout_weight=\ /> 7. ttom\ android:orientation=\ android:id=\ android:background=\ android:layout_width=\ android:layout_height=\> 8. ue\ android:id=\ android:layout_marginTop=\ android:drawableTop=\ style=\ /> 9. op=\ android:text=\ android:drawableTop=\able/icon_2_n\ style=\ /> 10. nTop=\ android:text=\ android:drawableTop=\drawable/icon_3_n\ style=\ /> 11. nTop=\ android:text=\ android:drawableTop=\drawable/icon_4_n\ style=\ /> 12. nTop=\ android:text=\ android:drawableTop=\e/icon_5_n\ style=\ /> 13.
styles.xml
[html] view plaincopyprint?
1.
home_btn_bg.xml
[html] view plaincopyprint?
1. 2. xmlns:android=\> 3. d:state_pressed=\ android:drawable=\ /> 4. d:drawable=\ /> 5. id:drawable=\ /> 6.
代码说明:
1. 需要注意的是他这里把TabWidget的Visibility设置成了gone!也就是默认难看的风格不见了:钮.
,取而代之的是5个带风格的单选按
2. 注意为单选按钮设置的style,其中最重要的是为其background设置了home_btn_bg.xml,也就是自定义了选中效果。 Java文件 [java] view plaincopyprint?
1. public class MainTabActivity extends TabActivity implements 2. OnCheckedChangeListener { 3.
4. private TabHost mHost; 5. private Intent mMBlogIntent; 6. private Intent mMoreIntent; 7. private Intent mInfoIntent; 8. private Intent mSearchIntent; 9. private Intent mUserInfoIntent; 10.
11. @Override
12. protected void onCreate(Bundle savedInstanceState) { 13. super.onCreate(savedInstanceState);
14. requestWindowFeature(Window.FEATURE_NO_TITLE); 15. setContentView(R.layout.maintabs); 16.
17. // ~~~~~~~~~~~~ 初始化
18. this.mMBlogIntent = new Intent(this, HomeListActivity.class); 19. this.mSearchIntent = new Intent(this, SearchSquareActivity.class); 20. this.mInfoIntent = new Intent(this, MessageGroup.class); 21. this.mUserInfoIntent = new Intent(this, MyInfoActivity.class); 22. this.mMoreIntent = new Intent(this, MoreItemsActivity.class); 23.
24. initRadios(); 25.
26. setupIntent(); 27. } 28. 29. /**
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库Android TabHost用法(4)在线全文阅读。
相关推荐: