不要直接
网格布局(网格
布局比较烂的) Fragment中布局GridView 照着下面代码改吧
你可以的private class MyGridView extends BaseAdapter{Context contextBoolean is_read[]int NTF[]int currentpublic MyGridView(Context context, Boolean is_read[], int NTF[], int current){this.context = contextthis.is_read = is_readthis.NTF = NTFthis.current = current}private void update(Boolean is_read[], int NTF[], int current) {this.is_read = is_readthis.NTF = NTFthis.current = currentMyGridView.this.notifyDataSetChanged()}@Overridepublic int getCount() {return is_read.length}@Overridepublic Object getItem(int position) {return (String.valueOf(is_read[position]) + NTF[position] + current)}@Overridepublic long getItemId(int position) {return position}@Overridepublic View getView(int position, View convertView, ViewGroup parent) {ViewHolder holderif (convertView == null) {convertView = LayoutInflater.from(context).inflate(R.layout.item_grid_quiz, parent, false)holder = new ViewHolder()holder.cir = (CircleImageView)convertView.findViewById(R.id.cir)holder.txt = (TextView)convertView.findViewById(R.id.txt)convertView.setTag(holder)}else {holder=(ViewHolder) convertView.getTag()}holder.txt.setText(String.valueOf(position +1))if(is_read[position]){holder.txt.setTextColor(getResources().getColor(R.color.style_white))}else{holder.txt.setTextColor(getResources().getColor(R.color.style_gray))}if(NTF[position] == 1){holder.cir.setImageResource(R.drawable.grid_item_green)}else if(NTF[position] == 2) {holder.cir.setImageResource(R.drawable.grid_item_red)}else {holder.cir.setImageResource(R.drawable.grid_item_null)}if (current == position){holder.cir.setBorderColor(getResources().getColor(R.color.style_white))}else {holder.cir.setBorderColor(getResources().getColor(R.color.style_null))}return convertView}}private class ViewHolder{TextView txtCircleImageView cir}引用的 https://www.jianshu.com/p/a436f5cec559
public class ItemGridDecoration extends RecyclerView.ItemDecoration {
用法
recycleView.addItemDecoration(new ItemGridDecoration(this, dip2px(4), R.color.red))
评论列表(0条)