| @ -0,0 +1,55 @@ | |||||
| package com.qhclh.ytzh.bean; | |||||
| /** | |||||
| * Created by 青花瓷 on 2017/11/30. | |||||
| */ | |||||
| public class FactryBean { | |||||
| private int id; | |||||
| private String name; | |||||
| private boolean isCheck; | |||||
| public FactryBean(int id, String name) { | |||||
| this.id = id; | |||||
| this.name = name; | |||||
| } | |||||
| public FactryBean(int id, String name, boolean isCheck) { | |||||
| this.id = id; | |||||
| this.name = name; | |||||
| this.isCheck = isCheck; | |||||
| } | |||||
| public int getId() { | |||||
| return id; | |||||
| } | |||||
| public void setId(int id) { | |||||
| this.id = id; | |||||
| } | |||||
| public String getName() { | |||||
| return name; | |||||
| } | |||||
| public void setName(String name) { | |||||
| this.name = name; | |||||
| } | |||||
| public boolean isCheck() { | |||||
| return isCheck; | |||||
| } | |||||
| public void setCheck(boolean check) { | |||||
| isCheck = check; | |||||
| } | |||||
| @Override | |||||
| public String toString() { | |||||
| return "FactryBean{" + | |||||
| "id=" + id + | |||||
| ", name='" + name + '\'' + | |||||
| ", isCheck=" + isCheck + | |||||
| '}'; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,30 @@ | |||||
| package com.qhclh.ytzh.ui; | |||||
| import android.content.Context; | |||||
| import android.util.AttributeSet; | |||||
| import android.widget.GridView; | |||||
| /** | |||||
| * Created by 青花瓷 on 2017/11/30. | |||||
| */ | |||||
| public class MyGridView extends GridView { | |||||
| public MyGridView(Context context, AttributeSet attrs) { | |||||
| super(context, attrs); | |||||
| } | |||||
| public MyGridView(Context context) { | |||||
| super(context); | |||||
| } | |||||
| public MyGridView(Context context, AttributeSet attrs, int defStyle) { | |||||
| super(context, attrs, defStyle); | |||||
| } | |||||
| @Override | |||||
| public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { | |||||
| int expandSpec = MeasureSpec.makeMeasureSpec( | |||||
| Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); | |||||
| super.onMeasure(widthMeasureSpec, expandSpec); | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,92 @@ | |||||
| package com.qhclh.ytzh.work.breedpoultry; | |||||
| import android.content.Context; | |||||
| import android.view.LayoutInflater; | |||||
| import android.view.View; | |||||
| import android.view.ViewGroup; | |||||
| import android.widget.BaseAdapter; | |||||
| import android.widget.CheckBox; | |||||
| import android.widget.CompoundButton; | |||||
| import com.qhclh.ytzh.R; | |||||
| import com.qhclh.ytzh.bean.FactryBean; | |||||
| import java.util.List; | |||||
| /** | |||||
| * Created by 青花瓷 on 2017/11/30. | |||||
| */ | |||||
| public class FactryAdapter extends BaseAdapter { | |||||
| private Context context; | |||||
| private List<FactryBean> list; | |||||
| private LayoutInflater layoutInflater; | |||||
| private List<Boolean> isCheck; | |||||
| public FactryAdapter(Context context, List<FactryBean> list, List<Boolean> isCheck) { | |||||
| this.context = context; | |||||
| this.list = list; | |||||
| this.isCheck = isCheck; | |||||
| layoutInflater = LayoutInflater.from(context); | |||||
| } | |||||
| public FactryAdapter(Context context, List<FactryBean> list) { | |||||
| this.context = context; | |||||
| this.list = list; | |||||
| layoutInflater = LayoutInflater.from(context); | |||||
| } | |||||
| @Override | |||||
| public int getCount() { | |||||
| return list.size(); | |||||
| } | |||||
| @Override | |||||
| public Object getItem(int i) { | |||||
| return list.get(i); | |||||
| } | |||||
| @Override | |||||
| public long getItemId(int i) { | |||||
| return list.get(i).getId(); | |||||
| } | |||||
| @Override | |||||
| public View getView(int i, View view, ViewGroup viewGroup) { | |||||
| FactryBean message = list.get(i); | |||||
| final ViewHolder viewHolder; | |||||
| if (view == null){ | |||||
| viewHolder = new ViewHolder(); | |||||
| view = layoutInflater.inflate(R.layout.item_factry,viewGroup,false); | |||||
| viewHolder.factry_name = view.findViewById(R.id.factry_name); | |||||
| view.setTag(viewHolder); | |||||
| }else { | |||||
| viewHolder = (ViewHolder) view.getTag(); | |||||
| } | |||||
| viewHolder.factry_name.setTag(i); | |||||
| viewHolder.factry_name.setChecked(isCheck.get(i)); | |||||
| viewHolder.factry_name.setText(message.getName()); | |||||
| viewHolder.factry_name.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { | |||||
| @Override | |||||
| public void onCheckedChanged(CompoundButton compoundButton, boolean b) { | |||||
| int pos = (int) compoundButton.getTag(); | |||||
| isCheck.set(pos, b); | |||||
| list.get(pos).setCheck(b); | |||||
| if (b){ | |||||
| viewHolder.factry_name.setTextColor(context.getResources().getColor(R.color.green029737)); | |||||
| }else { | |||||
| viewHolder.factry_name.setTextColor(context.getResources().getColor(R.color.black303030)); | |||||
| } | |||||
| } | |||||
| }); | |||||
| return view; | |||||
| } | |||||
| private class ViewHolder { | |||||
| public CheckBox factry_name; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,7 @@ | |||||
| <?xml version="1.0" encoding="utf-8"?> | |||||
| <selector xmlns:android="http://schemas.android.com/apk/res/android"> | |||||
| <item android:drawable="@drawable/shape_select" android:state_checked="true"></item> | |||||
| <item android:drawable="@drawable/shape_select" android:state_selected="true"></item> | |||||
| <item android:drawable="@drawable/shape_select" android:state_pressed="true"></item> | |||||
| <item android:drawable="@drawable/shape_bg1"></item> | |||||
| </selector> | |||||
| @ -0,0 +1,17 @@ | |||||
| <?xml version="1.0" encoding="utf-8"?> | |||||
| <shape xmlns:android="http://schemas.android.com/apk/res/android"> | |||||
| <solid android:color="@color/white" /> | |||||
| <stroke | |||||
| android:width="@dimen/dp_1" | |||||
| android:color="@color/green029737" /> | |||||
| <corners | |||||
| android:bottomLeftRadius="@dimen/dp_3" | |||||
| android:bottomRightRadius="@dimen/dp_3" | |||||
| android:topLeftRadius="@dimen/dp_3" | |||||
| android:topRightRadius="@dimen/dp_3" /> | |||||
| <size | |||||
| android:width="@dimen/dp_20" | |||||
| android:height="@dimen/dp_20" /> | |||||
| </shape> | |||||
| @ -1,7 +1,36 @@ | |||||
| <?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||||
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||
| android:orientation="vertical" android:layout_width="match_parent" | |||||
| android:layout_height="match_parent"> | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="match_parent" | |||||
| android:background="@color/greyf4f4f4" | |||||
| android:orientation="vertical"> | |||||
| <include layout="@layout/include_tool_bar"></include> | <include layout="@layout/include_tool_bar"></include> | ||||
| <ScrollView | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="match_parent"> | |||||
| <LinearLayout | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="match_parent" | |||||
| android:orientation="vertical"> | |||||
| <com.qhclh.ytzh.ui.MyGridView | |||||
| android:id="@+id/gv_dataanaly" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="match_parent" | |||||
| android:background="@color/white" | |||||
| android:columnWidth="100dp" | |||||
| android:gravity="center_horizontal" | |||||
| android:horizontalSpacing="10dp" | |||||
| android:numColumns="auto_fit" | |||||
| android:padding="@dimen/dp_10" | |||||
| android:scrollbars="none" | |||||
| android:stretchMode="columnWidth" | |||||
| android:verticalSpacing="15dp"></com.qhclh.ytzh.ui.MyGridView> | |||||
| </LinearLayout> | |||||
| </ScrollView> | |||||
| </LinearLayout> | </LinearLayout> | ||||
| @ -0,0 +1,18 @@ | |||||
| <?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"> | |||||
| <CheckBox | |||||
| android:id="@+id/factry_name" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="match_parent" | |||||
| android:background="@drawable/btn_check" | |||||
| android:button="@null" | |||||
| android:gravity="center_horizontal" | |||||
| android:padding="@dimen/dp_3" | |||||
| android:textColor="@color/black303030" | |||||
| android:textSize="@dimen/text_size_20" /> | |||||
| </LinearLayout> | |||||