首先我们先分析分类的页面
然后我们根据分析的图来布局分类的Frament
我们命名为fenleiframent.xml----------这是分类的布局
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> <ListView android:background="#F3F3F6" android:divider="#F3F3F6" android:dividerHeight="0.1dp" android:id="@+id/fen_lei_list_view" android:scrollbars="none" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent"> </ListView> <FrameLayout android:id="@+id/fen_lei_frame" android:layout_width="0dp" android:layout_weight="3" android:layout_height="match_parent"> </FrameLayout> </LinearLayout> </LinearLayout>
上面就是分类的布局,左边一个listview,右边一个framelayout
然后我们需要在fenleiframent写我们需要的代码了
package com.bw.eastofbeijing.view.fragment; import android.content.Intent; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ListView; import com.bw.eastofbeijing.R; import com.bw.eastofbeijing.model.bean.FenLeiBean; import com.bw.eastofbeijing.persenter.ShouYeFragmentP; import com.bw.eastofbeijing.utils.ChenJinUtil; import com.bw.eastofbeijing.utils.Constants; import com.bw.eastofbeijing.view.acvitity.CustomCaptrueActivity; import com.bw.eastofbeijing.view.acvitity.SuosouAcvitity; import com.bw.eastofbeijing.view.adapter.FenLeiLelftAdapter; import com.bw.eastofbeijing.view.iview.IHome; import com.google.gson.Gson; import java.io.IOException; import java.util.ArrayList; import java.util.List; import butterknife.BindView; import butterknife.ButterKnife; import okhttp3.ResponseBody; /** * 祁凯凯 on 2018/3/20 */ public class FenLeiFragment extends Fragment implements IHome,View.OnClickListener{ @BindView(R.id.fen_lei_list_view) ListView fen_lei_list_view; @BindView(R.id.fen_lei_frame) FrameLayout fen_lei_frame; @BindView(R.id.linear_layout) LinearLayout linear_layout; @BindView(R.id.sao_hei) ImageView sao_hei; private ShouYeFragmentP fragmentHomeP; private List<FenLeiBean.DataBean> dataBeans=new ArrayList<>(); private FenLeiLelftAdapter fenLeiLelftAdapter; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view=inflater.inflate(R.layout.fenleifragment,container,false); ButterKnife.bind(this,view);