购物app学习笔记-tab导航条
来源:互联网 发布:2016nba数据库统计 编辑:程序博客网 时间:2024/06/08 00:04
Xutils:https://github.com/wyouflf/xUtils
xUtils简介
· xUtils 包含了很多实用的android工具。
· xUtils 支持大文件上传,更全面的http请求协议支持(10种谓词),拥有更加灵活的ORM,更多的事件注解支持且不受混淆影响...
· xUitls 最低兼容android 2.2 (api level 8)
目前xUtils主要有四大模块:
·
DbUtils模块:
·
o android中的orm框架,一行代码就可以进行增删改查;
o 支持事务,默认关闭;
o 可通过注解自定义表名,列名,外键,唯一性约束,NOT NULL约束,CHECK约束等(需要混淆的时候请注解表名和列名);
o 支持绑定外键,保存实体时外键关联实体自动保存或更新;
o 自动加载外键关联实体,支持延时加载;
o 支持链式表达查询,更直观的查询语义,参考下面的介绍或sample中的例子。
·
ViewUtils模块:
·
o android中的ioc框架,完全注解方式就可以进行UI,资源和事件绑定;
o 新的事件绑定方式,使用混淆工具混淆后仍可正常工作;
o 目前支持常用的20种事件绑定,参见ViewCommonEventListener类和包com.lidroid.xutils.view.annotation.event。
·
HttpUtils模块:
·
o 支持同步,异步方式的请求;
o 支持大文件上传,上传大文件不会oom;
o 支持GET,POST,PUT,MOVE,COPY,DELETE,HEAD,OPTIONS,TRACE,CONNECT请求;
o 下载支持301/302重定向,支持设置是否根据Content-Disposition重命名下载的文件;
o 返回文本内容的请求(默认只启用了GET请求)支持缓存,可设置默认过期时间和针对当前请求的过期时间。
·
BitmapUtils模块:
·
o 加载bitmap的时候无需考虑bitmap加载过程中出现的oom和android容器快速滑动时候出现的图片错位等现象;
o 支持加载网络图片和本地图片;
o 内存管理使用lru算法,更好的管理bitmap内存;
o 可配置线程加载线程数量,缓存大小,缓存路径,加载显示动画等...
使用xUtils快速开发框架需要有以下权限:
<uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
项目源码地址:http://square.github.io/picasso
依赖OkHttp:http://square.github.io/okhttp
使用说明和注意事项就去官网上自己查看
RadioGroup的设置:
<RadioGroup android:id="@+id/radioGroup1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:orientation="horizontal" > <RadioButton android:id="@+id/radio0" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1"<span style="color:#FF0000;"><span style="font-size:24px;">设置勾选框按钮为空</span></span> android:button="@null" android:checked="true" android:gravity="center"<span style="font-size:24px;"><span style="color:#FF0000;">调用的是drawable里面的资源</span></span> android:drawableTop="@drawable/ic_tab_artists" android:text="团购" />
按钮的设置:
这是drawable的xml文件代码,用来实现点击状态和默认状态的切换:
</pre><pre name="code" class="html"><?xml version="1.0" encoding="utf-8"?><selectorxmlns:android="http://schemas.android.com/apk/res/android"><span style="font-size:18px;color:#FF0000;">设置选中的状态</span><item android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/ic_tab_albums_selected"/><item android:state_checked="true" android:state_pressed="false" android:drawable="@drawable/ic_tab_albums_selected"/><span style="font-size:18px;color:#FF0000;">设置默认的状态</span><item android:drawable="@drawable/ic_tab_albums_unselected"/></selector>
主函数的代码:
public class MainActivity extends FragmentActivity {<span style="color:#FF0000;">// 使用xutils注入bottom_bar</span>@ViewInject(R.id.bottom_bar)private RadioGroup bottom_bar;@ViewInject(R.id.layout_content)private FrameLayout layout_content;protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);<span style="color:#FF0000;">// 依赖注入我们就不用一个一个地去findView</span>ViewUtils.inject(this);}<span style="color:#FF0000;">// 进行注解,监听底部的bar的点击事件</span>@OnCheckedChange({ R.id.bottom_bar })public void onCheckedChanged(RadioGroup group, int checkedId) {int index=0;//通过选择的radiao来判断当前位置switch(checkedId){case R.id.radio0:index=0;break;case R.id.radio1:index=1;break;case R.id.radio2:index=2;break;case R.id.radio3:index=3;break;}Fragment fragment=(Fragment) fragments.instantiateItem(layout_content, index);fragments.setPrimaryItem(layout_content,0,fragment);//提交fragments.finishUpdate(layout_content);}<span style="color:#FF0000;">//重写restart方法,为了触发onCheckedChanged事件</span>protected void onStart() {super.onStart();bottom_bar.check(R.id.radio0);};//为RadioGroup添加adapterFragmentStatePagerAdapter fragments=new FragmentStatePagerAdapter(getSupportFragmentManager()) {public int getCount() {return 4;}public Fragment getItem(int arg0) {//下面四个实例化的对象是我们创建的填充fragment布局的类switch(arg0){case 0:return new FragmentIndex();case 1:return new FragmentNearby();case 2:return new FragmentMy();case 3:return new FragmentMore();default:return new FragmentIndex();}}};}
填充fragment的类的代码如下
public class FragmentIndex extends Fragment{public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {View view=LayoutInflater.from(getActivity()).inflate(R.layout.frag_index,null);return view;}<span style="color:#FF0000;">//重写setMenuVisibility方法,防止发生重叠现象</span>public void setMenuVisibility(boolean menuVisible) {super.setMenuVisibility(menuVisible);if(this.getView()!=null){this.getView().setVisibility(menuVisible?View.VISIBLE:View.GONE);}}}
- 购物app学习笔记-tab导航条
- tab导航条
- bootstrap学习笔记-导航和导航条
- bootstrap学习笔记之导航条基础
- bootstrap学习笔记之基础导航条
- Bootstrap3 导航条之个人学习笔记
- bootstrap框架学习笔记四(按钮、导航、导航条)
- Bootstrap学习笔记(六)导航条、分页导航
- Bootstrap学习笔记——导航条、分页导航
- jquery mobile学习笔记——navbar(导航条)
- 【学习笔记+实践】简单的导航条菜单制作
- css3学习过程中导航条的制作笔记
- 万能兼容所有浏览器导航条-学习笔记
- bootstrap导航条、分页导航学习笔记6-3(为导航条添加标题、二级菜单及状态)
- bootstrap导航条、分页导航学习笔记6-9(分页导航-带页码的分页导航)
- 购物车学习笔记
- 安卓开发文档学习笔记之实现ActionBar中Tab导航
- 安卓开发文档学习笔记之实现ActionBar中Tab导航
- 棋牌游戏服务器架构: 总体设计
- [iOS开发]如何用KissXML生成一个XML文件
- Android Studio/IntelliJIDEA 快捷键详解
- poj1018 枚举+剪枝
- thrift0.7.0在ubuntu11.04/11.10和centos6上的安装测试
- 购物app学习笔记-tab导航条
- 关于不同体系结构风格的简单认识
- F - Piggy-Bank HDU 1114 (完全背包的变形+初始化细节)
- JAVASE生成一定范围的随机数
- How to create a PV image for XEN
- 在Android 中使用KSOAP2调用WebService
- 百度坐标转火星坐标
- makefile 工程管理---那些年我们一起学习linux程序设计
- 实用JS代码大全