1. 程式人生 > >京東分類頁面的簡單實現

京東分類頁面的簡單實現

  1. mvp模式  view層展示資料的介面
    public interface IShowLeft_View {
        //給左側list展示資料(給左側recyclerview設定adapter並載入資料)
        void showGoodsList(List<Left_Bean.DataBean> data);
        //給右側list展示資料(給右側recyclerview設定adapter並載入資料)
        void showRightData(List<RightBean.DataBean> data);
        //報錯資訊的展示
        void showError(String error);
    }

  2. model層的介面
    public interface IShowleftlistener {
        //請求商品總分類介面,用於在圖一的左側列表上顯示
        void getGoodsCart(String url, GsonObjectCallback<Left_Bean> callback);
        //請求商品子分類類別的資料介面,顯示右側列表
        void getRightData(String url, GsonObjectCallback<RightBean> callback);
    }
    

  3. model層獲取資料
    import com.example.x1_yue.bean.Left_Bean;
    import com.example.x1_yue.bean.RightBean;
    import com.example.x1_yue.contract.IShowleftlistener;
    import com.example.x1_yue.model.utils.GsonObjectCallback;
    import com.example.x1_yue.model.utils.OKhttpclinte;
    
    /**
     * Created by CR on 2018/4/4.
     *  model負責  資料   處理;
     */
    
    public class IShowClassifyModel implements IShowleftlistener{
    
        //請求商品分類介面
        @Override
        public void getGoodsCart(String url, GsonObjectCallback<Left_Bean> callback) {
            OKhttpclinte.doGet(url,callback);
        }
        //請求商品 子 分類的網路介面
        @Override
        public void getRightData(String url, GsonObjectCallback<RightBean> callback) {
            OKhttpclinte.doGet(url,callback);
        }
    
    }
  4. presenter層,,view層與model層相關聯
    import android.util.Log;
    
    import com.example.x1_yue.bean.Left_Bean;
    import com.example.x1_yue.bean.RightBean;
    import com.example.x1_yue.contract.IShowLeft_View;
    import com.example.x1_yue.model.IShowClassifyModel;
    import com.example.x1_yue.model.utils.GsonObjectCallback;
    
    import java.io.IOException;
    import java.lang.ref.WeakReference;
    import java.util.List;
    
    import okhttp3.Call;
    
    /**
     * Created by CR on 2018/4/4.
     * presenter負責業務邏輯處理,是view層與model層的紐帶;
     */
    
    public class IShowGoods_Presenter {
        private IShowClassifyModel modle;
        //防止記憶體洩漏,將view的物件使用弱引用來管理
        private WeakReference<IShowLeft_View> reference;
        //presenter類構造方法,獲取model類例項;
        public IShowGoods_Presenter() {
            modle=new IShowClassifyModel();
        }
    
        public void attachView(IShowLeft_View view) {
            reference = new WeakReference<IShowLeft_View>(view);
        }
        public void detachView(IShowLeft_View view) {
            if (reference != null) {
                reference.clear();
                reference = null;
            }
        }
    
        //presenter類裡自定義的方法,實現業務邏輯
        public void getleftData(){
            //獲取圖一左側分類列表資料並展示
            modle.getGoodsCart("https://www.zhaoapi.cn/product/getCatagory", new GsonObjectCallback<Left_Bean>() {
                @Override
                public void onUi(Left_Bean left_bean) {
                    //圖一左側分類列表載入完成以後,右側預設顯示第一個分類對應的商品子分類列表
                    if (left_bean != null && left_bean.getData() != null) {
                        List<Left_Bean.DataBean> beans = left_bean.getData();
                        if (beans != null) {
                            //reference.get()獲取view層對應介面的例項
                            //顯示左側列表資料
                            reference.get().showGoodsList(beans);
                            if (beans.size()>0){
                                //如果左側資料不為空,右側預設顯示對應左側第一條資料的子分類;
                                getRightData(beans.get(0).getCid());
                            }
                        } else {
                            reference.get().showError("資料為空");
                        }
                    }
                }
    
                @Override
                public void onFailed(Call call, IOException e) {
                    reference.get().showError(e.getMessage());
                }
            });
        }
        //獲取圖一右側列表資料並展示
        public void showRightList(int cid) {
            getRightData(cid);
        }
    
        private void getRightData(int cid) {
            modle.getRightData("https://www.zhaoapi.cn/product/getProductCatagory?source=android&&cid="+cid, new GsonObjectCallback<RightBean>() {
                @Override
                public void onUi(RightBean rightBean) {
                    if (rightBean!=null&&rightBean.getData()!=null){
                        reference.get().showRightData(rightBean.getData());
                    }
                }
    
                @Override
                public void onFailed(Call call, IOException e) {
                }
            });
        }
    }

  5. 主頁面展示資料
            import android.os.Bundle;
            import android.support.annotation.Nullable;
            import android.support.v4.app.Fragment;
            import android.support.v7.widget.LinearLayoutManager;
            import android.support.v7.widget.RecyclerView;
            import android.util.Log;
            import android.view.LayoutInflater;
            import android.view.View;
            import android.view.ViewGroup;
            import android.widget.Toast;
    
            import com.example.x1_yue.R;
            import com.example.x1_yue.adapter.OnItemClickListner;
            import com.example.x1_yue.adapter.classifyLeftAdapter;
            import com.example.x1_yue.adapter.classifyRightAdapter;
            import com.example.x1_yue.bean.Left_Bean;
            import com.example.x1_yue.bean.RightBean;
            import com.example.x1_yue.contract.IShowLeft_View;
            import com.example.x1_yue.presenter.IShowGoods_Presenter;
    
            import java.util.List;
    
    /**
     * 分類頁面
     * Created by CR on 2018/4/3.
     */
    
    public class Classify_Fragment extends Fragment implements IShowLeft_View{
    
    
            private RecyclerView left_recy,right_recy;
            private IShowGoods_Presenter presenter;
            private classifyLeftAdapter adapter;
            private classifyRightAdapter rightAdapter;
    
            @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
            View view = inflater.inflate(R.layout.classify_fragment, container, false);
            left_recy = view.findViewById(R.id.left_recy);
            right_recy = view.findViewById(R.id.right_recy);
            //例項化presenter;
            presenter = new IShowGoods_Presenter();
            //初始化presenter對應的view
            presenter.attachView(this);
            //開始呼叫presenter內定義的方法,展示左側列表資料,並更新顯示右側列表資料;
             presenter.getleftData();
    
              //設定佈局管理器
            left_recy.setLayoutManager(new LinearLayoutManager(getContext()));
            //初始化左邊的介面卡
            adapter = new classifyLeftAdapter(getContext());
            left_recy.setAdapter(adapter);
             //設定佈局管理器
            right_recy.setLayoutManager(new LinearLayoutManager(getActivity()));
              //初始化右側列表對應的adapter,設定給右側列表
            rightAdapter = new classifyRightAdapter(getActivity());
            right_recy.setAdapter(rightAdapter);
            return view;
    }
    
            //左邊的資料
            @Override
            public void showGoodsList(List<Left_Bean.DataBean> data) {
                   if (data != null){
                           adapter.setList(data);
                   }
                    adapter.setClick(new OnItemClickListner() {
                            @Override
                            public void onItemClick(View view, int cid) {
    //                        Toast.makeText(getActivity(),"dianji",Toast.LENGTH_SHORT).show();
                             //左側列表的條目點選事件;
                            presenter.showRightList(cid);
                            }
                    });
            }
            //右邊的資料
            @Override
            public void showRightData(List<RightBean.DataBean> data) {
                    if (data!=null){
                            Log.i("====",data.size()+"");
                            rightAdapter.updateData(data);
                    }
    
            }
            //提示報錯資訊
            @Override
            public void showError(String error) {
                    Toast.makeText(getActivity(), error, Toast.LENGTH_SHORT).show();
            }
            //銷燬
            @Override
            public void onDestroy() {
                    super.onDestroy();
                    presenter.detachView(this);
            }
    
    
    }
    

  6. 左邊介面卡
    package com.example.x1_yue.adapter;
    
    import android.annotation.SuppressLint;
    import android.content.Context;
    import android.graphics.Color;
    import android.support.v7.widget.RecyclerView;
    import android.util.Log;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.TextView;
    
    import com.example.x1_yue.R;
    import com.example.x1_yue.bean.Left_Bean;
    
    import java.util.ArrayList;
    import java.util.List;
    
    /**
     * Created by CR on 2018/4/4.
     */
    
    public class classifyLeftAdapter extends RecyclerView.Adapter<classifyLeftAdapter.LeftViewHolder>{
        private Context context;
        private List<Left_Bean.DataBean> list;
        private int po=0;
    
        public classifyLeftAdapter(Context context) {
            this.context = context;
        }
    
        public void setList(List<Left_Bean.DataBean> list) {
            this.list = list;
    //        Log.i("TAG",list.size() + "=======");
            notifyDataSetChanged();
        }
    
        @Override
        public LeftViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            View view = LayoutInflater.from(context).inflate(R.layout.classity_item_layout, parent,false);
            LeftViewHolder holder = new LeftViewHolder(view);
            return holder;
        }
    
    
        @Override
        public void onBindViewHolder(LeftViewHolder holder, final int position) {
            if (po==position){
                holder.left_textview.setTextColor(Color.RED);
                holder.left_textview.setBackgroundColor(Color.parseColor("#eeeeee"));
            }else {
                holder.left_textview.setTextColor(Color.BLACK);
                holder.left_textview.setBackgroundColor(Color.WHITE);
            }
            holder.left_textview.setText(list.get(position).getName());
            holder.left_textview.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    listner.onItemClick(v,list.get(position).getCid());
                    po=position;
                    notifyDataSetChanged();
                }
            });
        }
    
        @Override
        public int getItemCount() {
            return list != null ? list.size() : 0;
        }
    
        //viewhodler
        class LeftViewHolder extends RecyclerView.ViewHolder{
            private TextView left_textview;
            public LeftViewHolder(View itemView) {
                super(itemView);
                left_textview = itemView.findViewById(R.id.classity_left_textview);
            }
          }
    //點選條目的監聽
      public OnItemClickListner listner;
      public void setClick(OnItemClickListner listner){
            this.listner =listner;
      }
    
    }
    

  7. 右邊的介面卡
    /**
     * Created by CR on 2018/4/6.
     * 圖一右側recyclerview的介面卡
     */
    
    public class classifyRightAdapter extends RecyclerView.Adapter<classifyRightAdapter.GroupViewHolder>{
        private List<RightBean.DataBean> list = new ArrayList<>();
        private Context context;
    
        public classifyRightAdapter(Context context) {
            this.context = context;
        }
        //重新整理資料
        public void updateData(List<RightBean.DataBean> list){
            this.list.clear();
            this.list.addAll(list);
            notifyDataSetChanged();
        }
    
    
        @Override
        public GroupViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            View view = LayoutInflater.from(context).inflate(R.layout.classify_right_layout, null);
            return new GroupViewHolder(view);
        }
    
        @Override
        public void onBindViewHolder(GroupViewHolder holder, int position) {
            holder.textView.setText(list.get(position).getName());
            //網格recyclerview的資料展示
            holder.recyclerView.setLayoutManager(new GridLayoutManager(context,3));
            MyAdapter adapter = new MyAdapter(context);
            //為圖一巢狀的recyclerview設定介面卡
            holder.recyclerView.setAdapter(adapter);
            adapter.addData(list.get(position).getList());
            Log.i("====",list.get(position).getName()+"-----");
        }
    
        @Override
        public int getItemCount() {
            return list.size();
        }
    
        class GroupViewHolder extends RecyclerView.ViewHolder {
            public TextView textView;
            public RecyclerView recyclerView;
            public GroupViewHolder(View itemView) {
                super(itemView);
                textView = (TextView) itemView.findViewById(R.id.item_title);
                recyclerView = (RecyclerView) itemView.findViewById(R.id.item_list);
            }
        }
    
    }
    

  8. 右邊recyclerview巢狀的介面卡
    /**
     * Created by CR on 2018/4/6.
     * 分類主頁右側資料子分類的recyclerview的介面卡
     */
    
    public class MyAdapter extends RecyclerView.Adapter<TextViewHolder>{
        private ArrayList<RightBean.DataBean.ListBean> list = new ArrayList<>();
        private Context context;
    
        public MyAdapter(Context context) {
            this.context = context;
        }
        public void addData(List<RightBean.DataBean.ListBean> data) {
            this.list.addAll(data);
            notifyDataSetChanged();
        }
    
        @Override
        public TextViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            View view = LayoutInflater.from(context).inflate(R.layout.classify_right_item_layout, null);
            final TextViewHolder holder = new TextViewHolder(view);
            view.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    context.startActivity(new Intent(context,SecondListActivity.class)
                    .putExtra("pscid",list.get(holder.getLayoutPosition()).getPcid()));
                }
            });
    
            return holder;
        }
    
        @Override
        public void onBindViewHolder(TextViewHolder holder, int position) {
            holder.textView.setText(list.get(position).getName());
            Glide.with(context).load(list.get(position).getIcon()).into(holder.img);
        }
    
        @Override
        public int getItemCount() {
            return list.size();
        }
    }
    

  9. 自定義recyclerview的監聽與viewholder
    public interface OnItemClickListner {
        void onItemClick(View view, int cid);
    }
    
    //viewholder
    
    /**
     * Created by CR on 2018/4/6.
     */
    
    public class TextViewHolder extends RecyclerView.ViewHolder {
        public TextView textView;
        public ImageView img;
    
        public TextViewHolder(View itemView){
            super(itemView);
            textView=(TextView)itemView.findViewById(R.id.mytitle);
            img=(ImageView)itemView.findViewById(R.id.myimg);
        }
    
    }
    
  10. 子分類展示的介面
    /**
     * Created by CR on 2018/4/6.
     * 圖二view介面
     */
    
    public interface IShowGoods {
    
        void showGoodsList(List<GoodsBean.DataBean> data);
    
    }
    

  11. 子分類model
    /**
     * Created by CR on 2018/4/6.
     */
    
    public class IShowGoodslistShowModle {
        public void  getGoodsList(String url, GsonObjectCallback<GoodsBean> callback){
            OKhttpclinte.doGet(url,callback);
        }
    
    }
    
  12. 子分類presenter層
    import com.example.x1_yue.bean.GoodsBean;
    import com.example.x1_yue.contract.IShowGoods;
    import com.example.x1_yue.model.IShowGoodslistShowModle;
    import com.example.x1_yue.model.utils.GsonObjectCallback;
    
    import java.io.IOException;
    import java.lang.ref.WeakReference;
    
    import okhttp3.Call;
    
    /**
     * Created by CR on 2018/4/6.
     */
    
    public class IShowGoods_Classify_Presenter {
    
        private IShowGoodslistShowModle modle;
        private WeakReference<IShowGoods> reference;
    
        public IShowGoods_Classify_Presenter() {
            modle = new IShowGoodslistShowModle();
        }
        public void  attachView(IShowGoods view){
            reference=new WeakReference<IShowGoods>(view);
        }
        public void detachView(){
            if(reference!=null){
                reference.clear();
                reference=null;
            }
        }
        public void getData(int pscid,int page){
            modle.getGoodsList("https://www.zhaoapi.cn/product/getProducts?pscid=" + pscid + "&page=" + page, new GsonObjectCallback<GoodsBean>() {
                @Override
                public void onUi(GoodsBean goodsBean) {
                    reference.get().showGoodsList(goodsBean.getData());
                }
    
                @Override
                public void onFailed(Call call, IOException e) {
    
                }
            });
    
        }
    }
  13. 子分類的主頁顯示
    public class SecondListActivity extends AppCompatActivity implements IShowGoods{
        private XRecyclerView recyclerView;
        private GoodsAdapter adapter;
        private IShowGoods_Classify_Presenter presenter;
        private int pscid;
        private int page = 1;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_second_list);
            //從上一個列表頁(圖一)獲取pscid
            Intent intent = getIntent();
            if (intent != null) {
                pscid = intent.getIntExtra("pscid", 0);
            }
            //隱藏左側列表,只顯示右側列表
            //findViewById(R.id.left_list).setVisibility(View.GONE);
            recyclerView = (XRecyclerView) findViewById(R.id.xlist);
            adapter = new GoodsAdapter(SecondListActivity.this);
            recyclerView.setAdapter(adapter);
            recyclerView.setLayoutManager(new LinearLayoutManager(SecondListActivity.this));
    //例項化presenter,關聯view
            presenter = new IShowGoods_Classify_Presenter();
            presenter.attachView(this);
            //通過presenter請求資料並顯示;
            if (pscid > 0) {
                presenter.getData(pscid, page);
            }
    
            recyclerView.setLoadingListener(new XRecyclerView.LoadingListener() {
                @Override
                public void onRefresh() {
                    page = 1;
                    presenter.getData(pscid, page);
                }
    
                @Override
                public void onLoadMore() {
                    page++;
                    presenter.getData(pscid, page);
                }
            });
        }
    
        @Override
        public void showGoodsList(List<GoodsBean.DataBean> data) {
    
            recyclerView.refreshComplete();
            recyclerView.loadMoreComplete();
            if (page > 1) {
                //顯示新增資料
                adapter.addList(data);
            } else {
                adapter.updateList(data);
            }
        }
    }

  14. 子分類的介面卡
    /**
     * Created by CR on 2018/4/6.
     */
    
    public class GoodsAdapter extends RecyclerView.Adapter<GoodsAdapter.GoodsViewHolder>{
    
    
        private Context context;
        private List<GoodsBean.DataBean> data = new ArrayList<>();
    
        public GoodsAdapter(Context context) {
            this.context = context;
        }
    
        //重新整理列表資料
        public void updateList(List<GoodsBean.DataBean> data) {
            this.data.clear();
            addList(data);
        }
    
        //載入下一頁資料
        public void addList(List<GoodsBean.DataBean> data) {
            this.data.addAll(data);
            notifyDataSetChanged();
        }
    
        @Override
        public GoodsViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            View view = LayoutInflater.from(context).inflate(R.layout.item_list_layout, parent, false);
            GoodsViewHolder holder = new GoodsViewHolder(view);
            return holder;
        }
    
        @Override
        public void onBindViewHolder(GoodsViewHolder holder, int position) {
    //設定item顯示的資料
            holder.title.setText(data.get(position).getTitle());
            holder.price.setText("原價:¥"+data.get(position).getPrice());
            holder.price.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG); //中劃線
            //holder.pricenow.setText("優惠價:¥"+data.get(position).getBargainPrice());
            holder.pricenow.setText(String.format(context.getString(R.string.goods_price),data.get(position).getBargainPrice()+""));
            //設定圖片
            String url=data.get(position).getImages();
            String[] urls=url.split("\\|");
            if(urls!=null&&urls.length>0){
                url=urls[0];
            }
            Glide.with(context).load(url).into(holder.img);
        }
    
        @Override
        public int getItemCount() {
            return data.size();
        }
    
        class GoodsViewHolder extends RecyclerView.ViewHolder {
            public TextView title, price, pricenow;
            public ImageView img;
    
            public GoodsViewHolder(View itemView) {
                super(itemView);
                title = (TextView) itemView.findViewById(R.id.item_goods_title);
                price = (TextView) itemView.findViewById(R.id.item_goods_price);
                pricenow = (TextView) itemView.findViewById(R.id.item_goods_pricenow);
                img = (ImageView) itemView.findViewById(R.id.item_goods_img);
            }
        }
    }
  15. 子分類的bean類
    package com.example.x1_yue.bean;
    
    import java.util.List;
    
    /**
     * Created by mamiaomiao on 2018/2/28.
     */
    
    public class GoodsBean {
    
        /**
         * msg : 請求成功
         * code : 0
         * data : [{"bargainPrice":22.9,"createtime":"2017-10-14T21:48:08","detailUrl":"https://item.m.jd.com/product/2542855.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t1930/284/2865629620/390243/e3ade9c4/56f0a08fNbd3a1235.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2137/336/2802996626/155915/e5e90d7a/56f0a09cN33e01bd0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t1882/31/2772215910/389956/c8dbf370/56f0a0a2Na0c86ea6.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2620/166/2703833710/312660/531aa913/57709035N33857877.jpg!q70.jpg","itemtype":2,"pid":24,"price":288,"pscid":2,"salenum":90,"sellerid":1,"subhead":"三隻松鼠零食特惠,專區滿99減50,滿199減100,火速搶購》","title":"三隻松鼠 堅果炒貨 零食奶油味 碧根果225g/袋"},{"bargainPrice":22.9,"createtime":"2017-10-14T21:38:26","detailUrl":"https://item.m.jd.com/product/2542855.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t1930/284/2865629620/390243/e3ade9c4/56f0a08fNbd3a1235.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2137/336/2802996626/155915/e5e90d7a/56f0a09cN33e01bd0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t1882/31/2772215910/389956/c8dbf370/56f0a0a2Na0c86ea6.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2620/166/2703833710/312660/531aa913/57709035N33857877.jpg!q70.jpg","itemtype":1,"pid":25,"price":399,"pscid":2,"salenum":100,"sellerid":2,"subhead":"三隻松鼠零食特惠,專區滿99減50,滿199減100,火速搶購》","title":"三隻松鼠 堅果炒貨 零食奶油味 碧根果225g/袋"},{"bargainPrice":22.9,"createtime":"2017-10-03T23:53:28","detailUrl":"https://item.m.jd.com/product/2542855.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t1930/284/2865629620/390243/e3ade9c4/56f0a08fNbd3a1235.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2137/336/2802996626/155915/e5e90d7a/56f0a09cN33e01bd0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t1882/31/2772215910/389956/c8dbf370/56f0a0a2Na0c86ea6.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2620/166/2703833710/312660/531aa913/57709035N33857877.jpg!q70.jpg","itemtype":0,"pid":26,"price":88,"pscid":2,"salenum":777,"sellerid":3,"subhead":"三隻松鼠零食特惠,專區滿99減50,滿199減100,火速搶購》","title":"三隻松鼠 堅果炒貨 零食奶油味 碧根果225g/袋"},{"bargainPrice":22.9,"createtime":"2017-10-14T21:38:26","detailUrl":"https://item.m.jd.com/product/2542855.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t1930/284/2865629620/390243/e3ade9c4/56f0a08fNbd3a1235.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2137/336/2802996626/155915/e5e90d7a/56f0a09cN33e01bd0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t1882/31/2772215910/389956/c8dbf370/56f0a0a2Na0c86ea6.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2620/166/2703833710/312660/531aa913/57709035N33857877.jpg!q70.jpg","itemtype":1,"pid":27,"price":488,"pscid":2,"salenum":666,"sellerid":4,"subhead":"三隻松鼠零食特惠,專區滿99減50,滿199減100,火速搶購》","title":"三隻松鼠 堅果炒貨 零食奶油味 碧根果225g/袋"},{"bargainPrice":22.9,"createtime":"2017-10-03T23:53:28","detailUrl":"https://item.m.jd.com/product/2542855.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t1930/284/2865629620/390243/e3ade9c4/56f0a08fNbd3a1235.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2137/336/2802996626/155915/e5e90d7a/56f0a09cN33e01bd0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t1882/31/2772215910/389956/c8dbf370/56f0a0a2Na0c86ea6.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2620/166/2703833710/312660/531aa913/57709035N33857877.jpg!q70.jpg","itemtype":0,"pid":28,"price":599,"pscid":2,"salenum":555,"sellerid":5,"subhead":"三隻松鼠零食特惠,專區滿99減50,滿199減100,火速搶購》","title":"三隻松鼠 堅果炒貨 零食奶油味 碧根果225g/袋"},{"bargainPrice":22.9,"createtime":"2017-10-14T21:48:08","detailUrl":"https://item.m.jd.com/product/2542855.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t1930/284/2865629620/390243/e3ade9c4/56f0a08fNbd3a1235.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2137/336/2802996626/155915/e5e90d7a/56f0a09cN33e01bd0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t1882/31/2772215910/389956/c8dbf370/56f0a0a2Na0c86ea6.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2620/166/2703833710/312660/531aa913/57709035N33857877.jpg!q70.jpg","itemtype":2,"pid":29,"price":588,"pscid":2,"salenum":444,"sellerid":6,"subhead":"三隻松鼠零食特惠,專區滿99減50,滿199減100,火速搶購》","title":"三隻松鼠 堅果炒貨 零食奶油味 碧根果225g/袋"},{"bargainPrice":22.9,"createtime":"2017-10-14T21:38:26","detailUrl":"https://item.m.jd.com/product/2542855.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t1930/284/2865629620/390243/e3ade9c4/56f0a08fNbd3a1235.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2137/336/2802996626/155915/e5e90d7a/56f0a09cN33e01bd0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t1882/31/2772215910/389956/c8dbf370/56f0a0a2Na0c86ea6.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2620/166/2703833710/312660/531aa913/57709035N33857877.jpg!q70.jpg","itemtype":1,"pid":30,"price":688,"pscid":2,"salenum":333,"sellerid":7,"subhead":"三隻松鼠零食特惠,專區滿99減50,滿199減100,火速搶購》","title":"三隻松鼠 堅果炒貨 零食奶油味 碧根果225g/袋"},{"bargainPrice":22.9,"createtime":"2017-10-03T23:53:28","detailUrl":"https://item.m.jd.com/product/2542855.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t1930/284/2865629620/390243/e3ade9c4/56f0a08fNbd3a1235.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2137/336/2802996626/155915/e5e90d7a/56f0a09cN33e01bd0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t1882/31/2772215910/389956/c8dbf370/56f0a0a2Na0c86ea6.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2620/166/2703833710/312660/531aa913/57709035N33857877.jpg!q70.jpg","itemtype":0,"pid":31,"price":788,"pscid":2,"salenum":222,"sellerid":8,"subhead":"三隻松鼠零食特惠,專區滿99減50,滿199減100,火速搶購》","title":"三隻松鼠 堅果炒貨 零食奶油味 碧根果225g/袋"},{"bargainPrice":22.9,"createtime":"2017-10-14T21:38:26","detailUrl":"https://item.m.jd.com/product/2542855.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t1930/284/2865629620/390243/e3ade9c4/56f0a08fNbd3a1235.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2137/336/2802996626/155915/e5e90d7a/56f0a09cN33e01bd0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t1882/31/2772215910/389956/c8dbf370/56f0a0a2Na0c86ea6.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2620/166/2703833710/312660/531aa913/57709035N33857877.jpg!q70.jpg","itemtype":1,"pid":32,"price":888,"pscid":2,"salenum":0,"sellerid":9,"subhead":"三隻松鼠零食特惠,專區滿99減50,滿199減100,火速搶購》","title":"三隻松鼠 堅果炒貨 零食奶油味 碧根果225g/袋"},{"bargainPrice":22.9,"createtime":"2017-10-03T23:43:53","detailUrl":"https://item.m.jd.com/product/2542855.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t1930/284/2865629620/390243/e3ade9c4/56f0a08fNbd3a1235.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2137/336/2802996626/155915/e5e90d7a/56f0a09cN33e01bd0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t1882/31/2772215910/389956/c8dbf370/56f0a0a2Na0c86ea6.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2620/166/2703833710/312660/531aa913/57709035N33857877.jpg!q70.jpg","itemtype":0,"pid":33,"price":988,"pscid":2,"salenum":0,"sellerid":10,"subhead":"三隻松鼠零食特惠,專區滿99減50,滿199減100,火速搶購》","title":"三隻松鼠 堅果炒貨 零食奶油味 碧根果225g/袋"}]
         * page : 1
         */
    
        private String msg;
        private String code;
        private String page;
        private List<DataBean> data;
    
        public String getMsg() {
            return msg;
        }
    
        public void setMsg(String msg) {
            this.msg = msg;
        }
    
        public String getCode() {
            return code;
        }
    
        public void setCode(String code) {
            this.code = code;
        }
    
        public String getPage() {
            return page;
        }
    
        public void setPage(String page) {
            this.page = page;
        }
    
        public List<DataBean> getData() {
            return data;
        }
    
        public void setData(List<DataBean> data) {
            this.data = data;
        }
    
        public static class DataBean {
      
            private double bargainPrice;
            private String createtime;
            private String detailUrl;
            private String images;
            private int itemtype;
            private int pid;
            private double price;
            private int pscid;
            private int salenum;
            private int sellerid;
            private String subhead;
            private String title;
    
            public double getBargainPrice() {
                return bargainPrice;
            }
    
            public void setBargainPrice(double bargainPrice) {
                this.bargainPrice = bargainPrice;
            }
    
            public String getCreatetime() {
                return createtime;
            }
    
            public void setCreatetime(String createtime) {
                this.createtime = createtime;
            }
    
            public String getDetailUrl() {
                return detailUrl;
            }
    
            public void setDetailUrl(String detailUrl) {
                this.detailUrl = detailUrl;
            }
    
            public String getImages() {
                return images;
            }
    
            public void setImages(String images) {
                this.images = images;
            }
    
            public int getItemtype() {
                return itemtype;
            }
    
            public void setItemtype(int itemtype) {
                this.itemtype = itemtype;
            }
    
            public int getPid() {
                return pid;
            }
    
            public void setPid(int pid) {
                this.pid = pid;
            }
    
            public double getPrice() {
                return price;
            }
    
            public void setPrice(double price) {
                this.price = price;
            }
    
            public int getPscid() {
                return pscid;
            }
    
            public void setPscid(int pscid) {
                this.pscid = pscid;
            }
    
            public int getSalenum() {
                return salenum;
            }
    
            public void setSalenum(int salenum) {
                this.salenum = salenum;
            }
    
            public int getSellerid() {
                return sellerid;
            }
    
            public void setSellerid(int sellerid) {
                this.sellerid = sellerid;
            }
    
            public String getSubhead() {
                return subhead;
            }
    
            public void setSubhead(String subhead) {
                this.subhead = subhead;
            }
    
            public String getTitle() {
                return title;
            }
    
            public void setTitle(String title) {
                this.title = title;
            }
        }
    }
    
  16. values資料夾下,string's下加入
    <string name="goods_price">優惠價:¥%1$s</string>





相關推薦

京東分類頁面簡單實現

mvp模式  view層展示資料的介面public interface IShowLeft_View { //給左側list展示資料(給左側recyclerview設定adapter並載入資料) void showGoodsList(List<Left_

RecyclerView分類頁面簡單使用 (之間傳值介面卡主頁面 整型id)

** 主頁面佈局 ** <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android

Android 仿京東分類頁面

activity_main <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns

樸素貝葉斯分類簡單實現文字情感分析

樸素貝葉斯的一般過程: ① 收集資料:可以使用任何方法。 ② 準備資料:需要數值型或者布林型資料。 ③ 分析資料:有大量特徵時,繪製特徵作用不大,此時使用直方圖效果更好。 ④ 訓練演算法:計算不同的獨立特徵的條件概率。 ⑤ 測試演算法:計算錯誤率。 ⑥ 使用演算法:一個常見

分類簡單實現

新增依賴--和 --網路許可權(自己新增) compile 'com.android.support:appcompat-v7:26.+' compile 'com.android.support.constraint:constraint-layout

python3 簡單實現從csv文件中讀取內容,並對內容進行分類統計

tmp spa writer ict 打開文件 while 類型 spl blog 新手python剛剛上路,在實際工作中遇到如題所示的問題,嘗試使用python3簡單實現如下,歡迎高手前來優化import csv #打開文件,用with打開可以不用去特意關閉file了

vue_cli下開發一個簡單的模塊權限系統之建立登錄頁面並且實現在瀏覽器輸入地址出現內容

all tro 標識 打開 logs 開發 內容 引入 系統 新建一個Login.vue(登錄頁面,先把Hello.vue的內容復制過來即可) 然後我們打開router下面的index.js,第一個箭頭:(引入vue路由)第二個箭頭(引入我們新建的Login.vue頁面

簡單實現iframe的高度根據頁面內容自適應(jQuery方式)

eight var 調用 pos jquery 出現 引用 main body 這篇文章主要介紹了簡單實現iframe的高度根據頁面內容自適應(jQuery方式),以及在ie瀏覽器下的相關問題 方式一: //註意:下面的代碼是放在和iframe同一個頁面中調用 $("

通過flask實現web頁面簡單的增刪改查

bug html red end pla pan fileutil log class 通過flask實現web頁面簡單的增刪改查 # 1.後臺程序falsk_web01.py #coding:utf-8 from flask import Flask

jQuery簡單實現iframe的高度根據頁面內容自適應的方法(轉)

var contents color iframe meid clas 簡單實現 方式 根據 本文實例講述了jQuery簡單實現iframe的高度根據頁面內容自適應的方法。分享給大家供大家參考,具體如下: 方式1: //註意:下面的代碼是放在和iframe同一個

Android 商品分類(簡單實現 僅供參考)

  //匯入依賴 implementation 'com.android.support:recyclerview-v7:28.0.0' //首先在activity頁面新增兩個水平的RecyclerView <?xml version="1.0" encoding="

JavaEE初學之jsp+JavaBean實現頁面簡單計算器

JavaEE初學之jsp+JavaBean實現頁面簡單計算器 這個學期剛剛學了JavaEE,簡單記錄一下,希望以後會有幫助。 實現效果 首先新建一個web project:Calculator,然後新建一個calculate.jsp檔案和CalculatorBean.jav

TensorFlow之神經網路簡單實現MNIST資料集分類

import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data mnist=input_data.read_data_sets("MNIST_data",one_hot=True) ba

使用Recyclerview實現仿京東分類

主佈局 ​​​​ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"   &n

recyclerview+viewpager實現分類fragment介面 仿京東分類介面

好久沒寫部落格了,今天決定寫一篇簡單的功能實現熱熱手 這是我2018年10月份在京東app錄製的他們的分類介面,今天主要就是實現這樣的一個分類的介面 整理思路 首先整理思路啊。整體介面的實現方式可能很多,但是需要儘可能的用簡單的方式,比如左邊的分類介面和右邊的

php 爬蟲的簡單實現, 獲取整個頁面, 再把頁面的資料匯入本地的檔案當中

$curlobj = curl_init(); //建立一個curl 的資源,下面要用的 curl_setopt($curlobj,CURLOPT_URL,"http://www.baidu.com

資料探勘筆記-分類-KNN-原理與簡單實現

public class KNNClassifier { private static void configureJob(Job job) { job.setJarByClass(KNNClassifier.class); job.setMapperClass(KNNMapper.cla

計算器頁面功能的簡單實現

<section> <input /><br /> <div class="opt">(</div> <div class="opt">)</div> <div clas

android之ViewPager簡單實現區域性頁面滑動效果

-Viewpager能實現什麼效果? -實現左右滑動,切換view的效果。 -既可以實現整個頁面左右滑動,也可以實現同一個頁面中區域性左右滑動。 搞清楚viewpager的作用後,開始寫一個簡單例子,實現同一個頁面中區域性滑動的效果。 在coding前要做的準備工作 2

瀑布流實現京東分類聯動點選長按效果

1.首先,導依賴 implementation'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.30' 2.在包裡配置 allprojects { repositories { google()