adapter包:
public class DianyingyuanAdapter extends BaseAdapter {
private ListView lvInput = null; //要绑定数据的ListView
private List<Plan> accountList = null; //数据源
private LayoutInflater inflater = null; //具体item布局
private Context context = null; //对应ListView所在activity
public DianyingyuanAdapter(ListView lvInput,
List<Plan> accountList){
this.accountList = accountList; //获取List数据源
this.lvInput = lvInput; //获取ListView
this.context = lvInput.getContext(); //获得listview所在的activty
this.inflater = LayoutInflater.from(context); //都获得activty的布局
}
@Override
//让app获取到当前加载数据的数量
public int getCount() {
return accountList.size();
}
@Override
//获得每一个数据源中指定位置的数据
public Object getItem(int position) {
return accountList.get(position);
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
//绑定数据到item布局的控件中去
// 当前数据位置 对应的视图 对应的activity
public View getView(int position, View convertView, ViewGroup parent) {
convertView = null;
//第一步,获取spend_list_item.xml布局的引用,这样才能获取它里面的控件
if(convertView==null) {
Log.i("test", "测试");
convertView = inflater.inflate(R.layout.dianyingyuan_item_activity,null);
TextView tvH_paiyingBianhao = (TextView) convertView.findViewById(R.id.tvH_paiyingBianhao);
TextView tvH_yingpianName = (TextView) convertView.findViewById(R.id.tvH_yingpianName);
TextView tvH_Dianyingyuan= (TextView) convertView.findViewById(R.id.tvH_Dianyingyuan);
TextView tvH_fangyingTime= (TextView) convertView.findViewById(R.id.tvH_fangyingTime);
//把当前指定postion位置的数据添加到控件中显示
tvH_paiyingBianhao.setText(""+accountList.get(position).getPlanid());
tvH_yingpianName.setText(accountList.get(position).getFilmname());
tvH_Dianyingyuan.setText(accountList.get(position).getCinemaname());
tvH_fangyingTime.setText(accountList.get(position).getDatetime());
}
return convertView;
}
}
----
public class PaiyingAdapter extends BaseAdapter {
private ListView lvInput = null; //要绑定数据的ListView
private List<Plan> accountList = null; //数据源
private LayoutInflater inflater = null; //具体item布局
private Context context = null; //对应ListView所在activity
public PaiyingAdapter(ListView lvInput,
List<Plan> accountList){
this.accountList = accountList; //获取List数据源
this.lvInput = lvInput; //获取ListView
this.context = lvInput.getContext(); //获得listview所在的activty
this.inflater = LayoutInflater.from(context); //都获得activty的布局
}
@Override
//让app获取到当前加载数据的数量
public int getCount() {
return accountList.size();
}
@Override
//获得每一个数据源中指定位置的数据
public Object getItem(int position) {
return accountList.get(position);
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
//绑定数据到item布局的控件中去
// 当前数据位置 对应的视图 对应的activity
public View getView(int position, View convertView, ViewGroup parent) {
convertView = null;
//第一步,获取spend_list_item.xml布局的引用,这样才能获取它里面的控件
if(convertView==null) {
Log.i("test", "测试");
convertView = inflater.inflate(R.layout.paiying_item_activity,null);
TextView tv_paiyingBianhao = (TextView) convertView.findViewById(R.id.tv_paiyingBianhao);
TextView tv_yingpianName = (TextView) convertView.findViewById(R.id.tv_yingpianName);
TextView tv_Dianyingyuan= (TextView) convertView.findViewById(R.id.tv_Dianyingyuan);
TextView tv_fangyingTime= (TextView) convertView.findViewById(R.id.tv_fangyingTime);
//把当前指定postion位置的数据添加到控件中显示
tv_paiyingBianhao.setText(""+accountList.get(position).getPlanid());
tv_yingpianName.setText(accountList.get(position).getFilmname());
tv_Dianyingyuan.setText(accountList.get(position).getCinemaname());
tv_fangyingTime.setText(accountList.get(position).getDatetime());
}
return convertView;
}
}
---
public class YingpianAdapter extends BaseAdapter{
private ListView lvInput = null; //要绑定数据的ListView
private List<Film> accountList = null; //数据源
private LayoutInflater inflater = null; //具体item布局
private Context context = null; //对应ListView所在activity
public YingpianAdapter(ListView lvInput,
List<Film> accountList){
this.accountList = accountList; //获取List数据源
this.lvInput = lvInput; //获取ListView
this.context = lvInput.getContext(); //获得listview所在的activty
this.inflater = LayoutInflater.from(context); //都获得activty的布局
}
@Override
//让app获取到当前加载数据的数量
public int getCount() {
return accountList.size();
}
@Override
//获得每一个数据源中指定位置的数据
public Object getItem(int position) {
return accountList.get(position);
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
//绑定数据到item布局的控件中去
// 当前数据位置 对应的视图 对应的activity
public View getView(int position, View convertView, ViewGroup parent) {
convertView = null;
//第一步,获取spend_list_item.xml布局的引用,这样才能获取它里面的控件
if(convertView==null) {
Log.i("test", "测试");
convertView = inflater.inflate(R.layout.yingpian_item_activity,null);
TextView tv_yingpian_Name = (TextView) convertView.findViewById(R.id.tv_yingpian_Name);
TextView tv_yingpian_Chandi = (TextView) convertView.findViewById(R.id.tv_yingpian_Chandi);
TextView tv_Jiaose= (TextView) convertView.findViewById(R.id.tv_Jiaose);
TextView tv_fangying_Jianjie= (TextView) convertView.findViewById(R.id.tv_fangying_Jianjie);
//把当前指定postion位置的数据添加到控件中显示
tv_yingpian_Name.setText(accountList.get(position).getFilmname());
tv_yingpian_Chandi.setText(accountList.get(position).getFactory());
tv_Jiaose.setText(accountList.get(position).getActor());
tv_fangying_Jianjie.setText(accountList.get(position).getSynopsis());
}
return convertView;
}
}
主包:
fragment:
public class yingpian_activity extends Fragment {
private EditText YingpianID;
private Button Yingpian_chaxun;
private ListView lvYingpian_Xinxi;
public yingpian_activity() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view= inflater.inflate(R.layout.activity_yingpian, container, false);
//http://localhost:8080/CinemaWeb/getAllPlansByFilm?film=芈月传
Yingpian_chaxun=(Button)view.findViewById(R.id.dianYing_Chaxun);
YingpianID=(EditText)view.findViewById(R.id.search_movieName);
lvYingpian_Xinxi=(ListView)view.findViewById(R.id.lvMovieXinXi);
Yingpian_chaxun.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String id=YingpianID.getText().toString();
//http://localhost:8080/CinemaWeb/getAllFilms
String uri= Global.serverUrl + "getAllPlansByFilm?film="+id;
Log.d("调试8",uri);
String jsonstring= HttpURLCon.getHttpContent(uri);
Log.d("调试5","####"+jsonstring);
ReturnData rjson2 = JSON.parseObject(jsonstring, ReturnData.class);
Log.d("调试6","####"+rjson2.result.toString());
List<Film> list= JSON.parseArray(rjson2.result.toString(),Film.class);
Log.d("调试7",""+"######"+list.size());
for(int i=0;i<list.size();i++){
Film obj = (Film)list.get(i);
Log.d("调试9",""+"######"+obj.getFilmname()+","+obj.getSynopsis());
}
YingpianAdapter adapter = new YingpianAdapter(lvYingpian_Xinxi,list);
lvYingpian_Xinxi.setAdapter(adapter);
}
});
return view;
}
}
***
public class paiyingxinxi_activity extends Fragment {
private ListView lvItem_paiying = null;
private Button chaxun;
private EditText et_shu_dianyingName;
private Spinner sp_moviesYuan;
private ArrayAdapter<CharSequence> sp_moviesyuan=null;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.activity_paiying, container, false);
lvItem_paiying=(ListView)view.findViewById(R.id.listmovies);
chaxun=(Button)view.findViewById(R.id.chaxun);
et_shu_dianyingName=(EditText)view.findViewById(R.id.shu_dianyingName);
sp_moviesYuan=(Spinner)view.findViewById(R.id.moviesYuan);
chaxun.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
String id=et_shu_dianyingName.getText().toString();
String uri= Global.serverUrl + "getAllPlanByCinema?cinema="+id;
String jsonstring= HttpURLCon.getHttpContent(uri);
Log.d("调试1","-----"+jsonstring);
ReturnData rjson = JSON.parseObject(jsonstring, ReturnData.class);
Log.d("调试2","-----"+rjson.result.toString());
List<Plan> list= JSON.parseArray(rjson.result.toString(),Plan.class);
Log.d("调试3",""+"-----"+list.size());
for(int i=0;i<list.size();i++){
Plan obj = (Plan)list.get(i);
Log.d("调试4",""+"-----"+obj.getCinemaname()+","+obj.getDatetime());
}
PaiyingAdapter adapter = new PaiyingAdapter(lvItem_paiying,list);
lvItem_paiying.setAdapter(adapter);
}
});
return view;
}
}
***
public class dianyingyuan_activity extends Fragment {
private Button Hedian;
private ListView movieYuan_Xinxi=null;
public dianyingyuan_activity() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View view= inflater.inflate(R.layout.activity_dianyingyuan, container, false);
movieYuan_Xinxi=(ListView)view.findViewById(R.id.movieYuan_Xinxi);
Hedian=(Button)view.findViewById(R.id.bt_Hengdian);
Hedian.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String uri= Global.serverUrl + "getAllPlanByCinema?cinema=横店电影院";
String jsonstring= HttpURLCon.getHttpContent(uri);
Log.d("调试1","-----"+jsonstring);
ReturnData rjson = JSON.parseObject(jsonstring, ReturnData.class);
Log.d("调试2","-----"+rjson.result.toString());
List<Plan> list= JSON.parseArray(rjson.result.toString(),Plan.class);
Log.d("调试3",""+"-----"+list.size());
for(int i=0;i<list.size();i++){
Plan obj = (Plan)list.get(i);
}
DianyingyuanAdapter adapter = new DianyingyuanAdapter(movieYuan_Xinxi,list);
movieYuan_Xinxi.setAdapter(adapter);
}
});
return view;
}
}
***
public class MyFragmentPagerAdapter extends FragmentPagerAdapter {
private List<Fragment> list;
public MyFragmentPagerAdapter(FragmentManager fm, List<Fragment> list) {
super(fm);
this.list = list;
}
@Override
public Fragment getItem(int position) {
return list.get(position);
}
@Override
public int getCount() {
return list.size();
}
}
***
main类:
public class MainActivity extends AppCompatActivity {
private CustomViewPager viewPager;
private RadioGroup radioGroup;
private RadioButton rb_paiying,rb_yingpian,rb_dianyingyuan;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
}
private void initView() {
radioGroup=(RadioGroup)findViewById(R.id.radioGroup);
rb_dianyingyuan=(RadioButton)findViewById(R.id.rb_dianyingyuan);
rb_paiying=(RadioButton)findViewById(R.id.rb_paiying);
rb_yingpian=(RadioButton)findViewById(R.id.rb_yingpianxinxi);
//RadioGroup选中状态改变监听
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (checkedId) {
case R.id.rb_paiying:
/**
* setCurrentItem第二个参数控制页面切换动画
* true:打开/false:关闭
*/
viewPager.setCurrentItem(0, false);
break;
case R.id.rb_yingpianxinxi:
viewPager.setCurrentItem(1, false);
break;
case R.id.rb_dianyingyuan:
viewPager.setCurrentItem(2, false);
break;
}
}
});
/**
* ViewPager部分
*/
viewPager = (CustomViewPager) findViewById(R.id.viewPager);
paiyingxinxi_activity paiying = new paiyingxinxi_activity();
yingpian_activity yingpian = new yingpian_activity();
dianyingyuan_activity dianyingyuan = new dianyingyuan_activity();
//将View添加到list中进行管理
List<Fragment> alFragment = new ArrayList<Fragment>();
alFragment.add(paiying);
alFragment.add(yingpian);
alFragment.add(dianyingyuan);
//ViewPager设置适配器
viewPager.setAdapter(new MyFragmentPagerAdapter(getSupportFragmentManager(), alFragment));
//ViewPager显示第一个Fragment
viewPager.setCurrentItem(0);
//ViewPager页面切换监听
viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
//通过页面的切换,来让RadioButton按钮也一切同步
public void onPageSelected(int position) {
switch (position) {
case 0:
radioGroup.check(R.id.rb_paiying);
break;
case 1:
radioGroup.check(R.id.rb_yingpianxinxi);
break;
case 2:
radioGroup.check(R.id.rb_dianyingyuan);
break;
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
}
}
ViewPager类:
public class CustomViewPager extends ViewPager {
private boolean enabled = false;
public CustomViewPager(Context context) {
super(context);
}
public CustomViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
// 触摸事件不触发
if (this.enabled) {
return super.onTouchEvent(event);
}
return false;
}
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
// 不处理触摸拦截事件
if (this.enabled) {
return super.onInterceptTouchEvent(event);
}
return false;
}
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
// 分发事件,这个是必须要的,如果把这个方法覆盖了,那么ViewPager的子View就接收不到事件了
if (this.enabled) {
return super.dispatchTouchEvent(event);
}
return super.dispatchTouchEvent(event);
}
public void setPagingEnabled(boolean enabled) {
this.enabled = enabled;
}
}
xml:
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_main"
android:layout_width="match_parent" android:layout_height="match_parent"
tools:context="com.example.blue.cinema_2.MainActivity">
<!--单选按钮组设置于窗体底部-->
<RadioGroup
android:id="@+id/radioGroup"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_alignParentBottom="true"
android:background="@color/white"
android:orientation="horizontal">
<RadioButton
android:layout_marginTop="2.0dip"
android:text="排影信息"
android:drawableTop="@drawable/paiyingxinxi_item"
android:id="@+id/rb_paiying"
style="@style/style_RadioButton"/>
<RadioButton
android:layout_marginTop="2.0dip"
android:text="电影信息"
android:drawableTop="@drawable/yingpianxinxi_item"
android:id="@+id/rb_yingpianxinxi"
style="@style/style_RadioButton"/>
<RadioButton
android:layout_marginTop="2.0dip"
android:text="电影院"
android:drawableTop="@drawable/dianyingyuan_item"
android:id="@+id/rb_dianyingyuan"
style="@style/style_RadioButton"/>
</RadioGroup>
<util.CustomViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/radioGroup" />
</RelativeLayout>
activity_paiying.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_paiying"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.blue.cinema_2.paiyingxinxi_activity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Spinner
android:layout_width="100dp"
android:layout_height="match_parent"
android:id="@+id/moviesYuan"
android:entries="@array/movie"
android:background="@color/grey"
/>
<EditText
android:layout_width="180dp"
android:layout_height="wrap_content"
android:text="横店电影院"
android:id="@+id/shu_dianyingName"/>
<Button
android:layout_width="60dp"
android:layout_height="wrap_content"
android:id="@+id/chaxun"
android:text="查询"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="排影编号"
android:background="@color/aqua"/>
<TextView
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="影片名称"
android:background="@color/aqua"/>
<TextView
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="电影院"
android:background="@color/aqua"/>
<TextView
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="放映日期"
android:background="@color/aqua"/>
</LinearLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/listmovies">
</ListView>
</LinearLayout>
activity_dianyingyuan.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_dianyingyuan"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.blue.cinema_2.dianyingyuan_activity">
<Button
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="电影院名称"
android:textSize="30sp"
android:background="@color/aqua"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="横店电影院"
android:id="@+id/bt_Hengdian"/>
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/movieYuan_Xinxi">
</ListView>
</LinearLayout>
activity_yingpian.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_yingpian"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.blue.cinema_2.yingpian_activity">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:layout_width="200dp"
android:layout_height="wrap_content"
android:id="@+id/search_movieName"
android:text="中国机长我和我的祖国复仇者联盟4哪吒之魔童降世"/>
<Button
android:layout_marginLeft="100dp"
android:layout_width="70dp"
android:layout_height="wrap_content"
android:text="查询"
android:id="@+id/dianYing_Chaxun"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@color/aqua">
<TextView
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="影片名称"/>
<TextView
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="影片产地"/>
<TextView
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="主要演员"/>
<TextView
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="影片简称"/>
</LinearLayout>
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/lvMovieXinXi">
</ListView>
</LinearLayout>
</LinearLayout>
dianyingyuan_item_activity.xml: 带item都是子布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:layout_width="50dp"
android:layout_height="wrap_content"
android:id="@+id/tvH_paiyingBianhao"
android:layout_marginLeft="2dp"
android:text="001" />
<TextView
android:layout_width="100dp"
android:layout_height="wrap_content"
android:id="@+id/tvH_yingpianName"
android:text="复仇者联盟4" />
<TextView
android:layout_width="100dp"
android:layout_height="wrap_content"
android:id="@+id/tvH_Dianyingyuan"
android:text="万达影院"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tvH_fangyingTime"
android:text="2019-12-21 12:30" />
</LinearLayout>
</LinearLayout>
paiying_item_activity.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:layout_width="50dp"
android:layout_height="wrap_content"
android:id="@+id/tv_paiyingBianhao"
android:layout_marginLeft="2dp"
android:text="001"
/>
<TextView
android:layout_width="100dp"
android:layout_height="wrap_content"
android:id="@+id/tv_yingpianName"
android:text="复仇者联盟4"
/>
<TextView
android:layout_width="100dp"
android:layout_height="wrap_content"
android:id="@+id/tv_Dianyingyuan"
android:text="万达影院"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tv_fangyingTime"
android:text="2019-12-21 12:30"
/>
</LinearLayout>
</LinearLayout>
yingpian_item_activity.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="哪吒之魔童降世"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv_yingpian_Name"
android:layout_weight="1"
/>
<TextView
android:text="横店"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:id="@+id/tv_yingpian_Chandi"
android:layout_weight="1" />
<TextView
android:text="哪吒、敖丙"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:id="@+id/tv_Jiaose"
android:layout_weight="1" />
<TextView
android:text="1111111111111"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:id="@+id/tv_fangying_Jianjie"
android:layout_weight="1" />
</LinearLayout>
dianyingyuan_item.xml:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@drawable/balance_on"></item>
<item android:drawable="@drawable/balance_off"></item>
</selector>
paiyingxinxi_item.xml:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@drawable/balance_on"></item>
<item android:drawable="@drawable/balance_off"></item>
</selector>
yingpianxinxi_item:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@drawable/balance_on"></item>
<item android:drawable="@drawable/balance_off"></item>
</selector>
rb_focus_color.xml:
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_checked="true" android:color="@color/colorPrimary"></item>
<item android:state_checked="false" android:color="@color/gray"></item>
</selector>