admin
2022-08-09 399ac289f80b7a40aa4210341db6b447cacdcf14
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package com.tejia.lijin.app.ui.category;
 
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;
 
import com.tejia.lijin.app.R;
import com.tejia.lijin.app.entity.FirstCategory;
 
import java.util.List;
 
/**
 * Created by weikou2015 on 2017/6/20.
 */
 
public class FirstCategoryAdapter1 extends BaseAdapter {
 
    private Context mContext;
 
    private List<FirstCategory> mList;
 
    public FirstCategoryAdapter1(Context context, List<FirstCategory> list) {
 
        this.mContext = context;
        this.mList = list;
    }
 
    @Override
    public int getCount() {
        return mList == null ? 0 : mList.size();
    }
 
    @Override
    public long getItemId(int position) {
        return position;
    }
 
    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }
 
    @Override
    public View getView(int position, View view, ViewGroup parent) {
        view = LayoutInflater.from(mContext).inflate(R.layout.item_category1, null);
        LinearLayout ll_category_item1 = view.findViewById(R.id.ll_category_item1);
        View v_red = view.findViewById(R.id.v_red);
        TextView tv = view.findViewById(R.id.tv_name);
        tv.setText(mList.get(position).getName());
        if (sPosition == position) {
            ll_category_item1.setBackgroundColor(mContext.getResources().getColor(R.color.white));
            tv.setTextColor(mContext.getResources().getColor(R.color.theme));
            v_red.setVisibility(View.VISIBLE);
        } else {
            ll_category_item1.setBackgroundColor(mContext.getResources().getColor(R.color.register_gray));
            tv.setTextColor(mContext.getResources().getColor(R.color.black2));
        }
        return view;
    }
 
    public int sPosition = 0;
 
    public void getPosition(int position) {
        sPosition = position;
        notifyDataSetChanged();
    }
}