仿京东的放分类页面

该博客介绍了如何仿照京东的分类页面进行布局设计。首先分析页面结构,然后创建名为fenleiframent.xml的布局文件,包含左侧ListView和右侧FrameLayout。接着在Frament中使用MVP模式编写代码,实现ListView点击事件并传递数据。通过接口处理JSON数据,完成分类页面的功能。
摘要由CSDN通过智能技术生成

首先我们先分析分类的页面


然后我们根据分析的图来布局分类的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);
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值