首先是权限
然后布局
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</android.support.v4.view.ViewPager>
<RadioGroup
android:id="@+id/radiogroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:id="@+id/radioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="@null"
android:gravity="center"
android:padding="8dp"
android:text="list列表" />
<RadioButton
android:id="@+id/radioButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="@null"
android:gravity="center"
android:padding="8dp"
android:text="grid列表" />
</RadioGroup>
Item布局
android:layout_height="match_parent"
android:orientation="horizontal">
现在可以写个点击变色
接着写Fragment布局
Java.class

寻找插件 主界面添加 继承FragmentActivity

设置适配器

MyFragmentAdapter里

按钮与页面联动

内含点击变色

布局完成 开始写内部类Http


这时候就该写数据的封装(不要忘记导包 + gson+image-loder:1.9.5)
建App 看一下权限里是否存在

接着是第一个的页面的完成

Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what) {
case 0:
List<JsonListBean.ResultBean> list = (List<JsonListBean.ResultBean>) msg.obj;
//展示到listview上
listView.setAdapter(new MyAdapter(list,getActivity()));
break;
适配器里Adapter

Task以完成第二个页面

Grid的页面

本文详细介绍了一款安卓应用的布局设计过程,包括使用ViewPager和RadioGroup实现动态切换的列表展示,以及Fragment在应用中的具体应用。从权限设置、布局文件编写到内部类Http的数据封装,再到App权限检查,全面覆盖了安卓应用开发的关键步骤。

370

被折叠的 条评论
为什么被折叠?



