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();
|
}
|
}
|