这是CartActivity类:
package org.frxm.yuekao;
import android.content.ContentValues;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.drawable.GradientDrawable;
import android.support.v4.widget.CursorAdapter;
import android.support.v4.widget.SimpleCursorAdapter;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import java.util.List;
public class CartActivity extends AppCompatActivity {
MyHelper helper;
SQLiteDatabase db;
private ListView lv;
private CheckBox cc_tv;
private LinearLayout ll;
List<CheckBox> cbs = new ArrayList<>();
List<Shop> list = new ArrayList<>();
int total = 0;
private TextView c_total;
MyListAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cart);
lv = (ListView) findViewById(R.id.lv);
cc_tv = (CheckBox) findViewById(R.id.c_all);
c_total = (TextView) findViewById(R.id.c_total);
ll = (LinearLayout) findViewById(R.id.ll_cb);
helper = new MyHelper(this);
db = helper.getWritableDatabase();
//实例化适配器
adapter = new MyListAdapter(list, this);
lv.setAdapter(adapter);
//查询数据,刷新
loadData();
//长按事件
lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
//删除
db.delete("shop", "_id=?", new String[]{String.valueOf(list.get(position).getId())});
//查询数据,刷新
loadData();
return false;
}
});
//全选事件
cc_tv.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
//循环有多少个CheckBox次数,如果当前全选是选中,每个CheckBox都选中,否则都不选中
for (int i = 0; i < cbs.size(); i++) {
if (isChecked) {
cbs.get(i).setChecked(true);
} else {
cbs.get(i).setChecked(false);
}
}
}
});
}
//结算
public void click(View view) {
//循环看哪个CheckBox是选中的,就修改当前CheckBox的索引对应的数据,结算状态为true
for (int i = 0; i < cbs.size(); i++) {
if (cbs.get(i).isChecked()) {
ContentValues cv = new ContentValues();
cv.put("flag", true);
db.update("shop", cv, "_id=?", new String[]{String.valueOf(list.get(i).getId())});
}
}
//开启服务
Intent intent=new Intent(this,MyService.class);
startService(intent);
loadData();
}
private void loadData() {
//清空数据源
list.clear();
cbs.clear();
//清空坐标布局里面所有CheckBox
ll.removeAllViews();
Cursor shop = db.query("shop", null, null, null, null, null, null);
Log.i("tag", "" + shop.getCount());
/*adapter=new SimpleCursorAdapter(this,R.layout.list_item,shop,
new String[]{"title","image","price"},new int[]{
R.id.c_title,R.id.c_iv,R.id.c_price
}, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);*/
while (shop.moveToNext()) {
Shop shop1 = new Shop();
//循环取出每列
final int _id = shop.getInt(0);
String title = shop.getString(1);
String image = shop.getString(2);
final String price = shop.getString(3);
String flag = shop.getString(4);
//把每列赋给实体
shop1.setId(_id);
shop1.setFlag(false);
shop1.setImage(image);
shop1.setPrice(price);
shop1.setTitle(title);
//把实体放进集合
list.add(shop1);
//生成CheckBox
CheckBox cb = new CheckBox(this);
cb.setHeight(80);
cb.setGravity(Gravity.CENTER_VERTICAL);
//状态改变事件,如果当前CheckBox是选中状态,就把总金额+当前价格,否则—
cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
total += Integer.getInteger(price);
} else {
total -= Integer.getInteger(price);
}
c_total.setText("合計:¥" + total);
}
});
//把生成的CheckBox添加到CheckBox集合里
cbs.add(cb);
//把生成的CheckBox添加到左边的布局里
ll.addView(cb);
//刷新数据
adapter.notifyDataSetChanged();
}
}
}
这是Food类:
package org.frxm.yuekao;
import java.io.Serializable;
import java.util.List;
/**
* Created by 谢晨 on 2018/1/16.
*/
public class Foods implements Serializable{
/**
* ret : 1
* data : [{"id":"8289","title":"油焖大虾","pic":"http://www.qubaobei.com/ios/cf/uploadfile/132/9/8289.jpg","collect_num":"1653","food_str":"大虾 葱 生姜 植物油 料酒","num":1653},{"id":"2127","title":"四川回锅肉","pic":"http://www.qubaobei.com/ios/cf/uploadfile/132/3/2127.jpg","collect_num":"1584","food_str":"猪肉 青蒜 青椒 红椒 姜片","num":1584},{"id":"30630","title":"超简单芒果布丁","pic":"http://www.qubaobei.com/ios/cf/uploadfile/132/31/30630.jpg","collect_num":"1517","food_str":"QQ糖 牛奶 芒果","num":1517},{"id":"9073","title":"家常红烧鱼","pic":"http://www.qubaobei.com/ios/cf/uploadfile/132/10/9073.jpg","collect_num":"1416","food_str":"鲜鱼 姜 葱 蒜 花椒","num":1416},{"id":"10097","title":"家常煎豆腐","pic":"http://www.qubaobei.com/ios/cf/uploadfile/132/11/10097.jpg","collect_num":"1402","food_str":"豆腐 新鲜红椒 青椒 葱花 油","num":1402},{"id":"10509","title":"水煮肉片","pic":"http://www.qubaobei.com/ios/cf/uploadfile/132/11/10509.jpg","collect_num":"1335","food_str":"瘦猪肉 生菜 豆瓣酱 干辣椒 花椒","num":1335},{"id":"46968","title":"红糖苹果银耳汤","pic":"http://www.qubaobei.com/ios/cf/uploadfile/132/47/46968.jpg","collect_num":"1244","food_str":"银耳 苹果 红糖","num":1244},{"id":"10191","title":"麻婆豆腐","pic":"http://www.qubaobei.com/ios/cf/uploadfile/132/11/10191.jpg","collect_num":"1211","food_str":"豆腐 肉末 生抽 白糖 芝麻油","num":1211},{"id":"2372","title":"皮蛋瘦肉粥","pic":"http://www.qubaobei.com/ios/cf/uploadfile/132/3/2372.jpg","collect_num":"1143","food_str":"大米 皮蛋 猪肉 油条 香葱","num":1143},{"id":"2166","title":"蚂蚁上树","pic":"http://www.qubaobei.com/ios/cf/uploadfile/132/3/2166.jpg","collect_num":"1136","food_str":"红薯粉 肉 姜 蒜 花椒","num":1136},{"id":"2262","title":"糖醋肉","pic":"http://www.qubaobei.com/ios/cf/uploadfile/132/3/2262.jpg","collect_num":"1072","food_str":"猪肉 红椒 黄椒 洋葱 蛋清","num":1072},{"id":"9971","title":"鱼香豆腐","pic":"http://www.qubaobei.com/ios/cf/uploadfile/132/10/9971.jpg","collect_num":"1002","food_str":"豆腐 木耳 胡萝卜 香葱 番茄酱","num":1002},{"id":"10172","title":"干煸四季豆","pic":"http://www.qubaobei.com/ios/cf/uploadfile/132/11/10172.jpg","collect_num":"987","food_str":"四季豆 干辣椒 蒜头 酱油 糖","num":987},{"id":"2685","title":"胡萝卜肉末蒸蛋","pic":"http://www.qubaobei.com/ios/cf/uploadfile/132/3/2685.jpg","collect_num":"911","food_str":"胡萝卜 肉 蛋 生抽 盐","num":911},{"id":"9972","title":"虎皮青椒","pic":"http://www.qubaobei.com/ios/cf/uploadfile/132/10/9972.jpg","collect_num":"886","food_str":"青辣椒 大蒜 香醋 白糖 生抽","num":886},{"id":"10437","title":"叉烧排骨","pic":"http://www.qubaobei.com/ios/cf/uploadfile/132/11/10437.jpg","collect_num":"794","food_str":"排骨 李锦记叉烧酱 植物油 清水 油菜","num":794},{"id":"2892","title":"\u201c五行\u201d彩蔬汤","pic":"http://www.qubaobei.com/ios/cf/uploadfile/132/3/2892.jpg","collect_num":"755","food_str":"黑木耳 玉米 牛蒡 胡萝卜 西兰花","num":755},{"id":"33783","title":"美人豆浆","pic":"http://www.qubaobei.com/ios/cf/uploadfile/132/34/33783.jpg","collect_num":"753","food_str":"黄豆 红豆 绿豆 黑豆 黑米","num":753},{"id":"2348","title":"麻辣肉丝面","pic":"http://www.qubaobei.com/ios/cf/uploadfile/132/3/2348.jpg","collect_num":"752","food_str":"面条 肉丝 淀粉 酱油 辣椒","num":752},{"id":"10044","title":"土豆炖翅根","pic":"http://www.qubaobei.com/ios/cf/uploadfile/132/11/10044.jpg","collect_num":"750","food_str":"土豆 翅根 葱 姜 料酒","num":750}]
*/
private int ret;
private List<DataBean> data;
public int getRet() {
return ret;
}
public void setRet(int ret) {
this.ret = ret;
}
public List<DataBean> getData() {
return data;
}
public void setData(List<DataBean> data) {
this.data = data;
}
public static class DataBean implements Serializable{
/**
* id : 8289
* title : 油焖大虾
* pic : http://www.qubaobei.com/ios/cf/uploadfile/132/9/8289.jpg
* collect_num : 1653
* food_str : 大虾 葱 生姜 植物油 料酒
* num : 1653
*/
private String id;
private String title;
private String pic;
private String collect_num;
private String food_str;
private int num;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getPic() {
return pic;
}
public void setPic(String pic) {
this.pic = pic;
}
public String getCollect_num() {
return collect_num;
}
public void setCollect_num(String collect_num) {
this.collect_num = collect_num;
}
public String getFood_str() {
return food_str;
}
public void setFood_str(String food_str) {
this.food_str = food_str;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
}
}
Fragment1类:
public class Fragment1 extends Fragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View inflate = inflater.inflate(R.layout.fragment_a, null);
return inflate;
}
}
Fragment2类:
public class Fragment2 extends Fragment {
String path="http://www.qubaobei.com/ios/cf/dish_list.php?stage_id=1&limit=20&page=1";
private Button button;
private GridView gv;
private EditText et_search;
List<Foods.DataBean> newsList;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View inflate = inflater.inflate(R.layout.fragment_b, null);
et_search = (EditText) inflate.findViewById(R.id.ed1);
et_search.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if(keyCode==KeyEvent.KEYCODE_ENTER){
String name = et_search.getText().toString();
for (int i = 0; i <newsList.size() ; i++) {
if(newsList.get(i).getTitle().contains(name)){
Toast.makeText(getContext(),"存在这条数据"+newsList.get(i).getTitle(),Toast.LENGTH_SHORT).show();
}
}
}
return true;
}
});
gv = (GridView) inflate.findViewById(R.id.gv);
button = ((Button) inflate.findViewById(R.id.b1));
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new MyAsyncTask().execute();
}
});
gv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent=new Intent(getContext(),ShopActivity.class);
intent.putExtra("food",newsList.get(position));
startActivity(intent);
}
});
return inflate;
}
class MyAsyncTask extends AsyncTask<Void,Void,String>{
@Override
protected String doInBackground(Void... params) {
try {
Log.i("aaa",path);
URL url=new URL(path);
HttpURLConnection huc=(HttpURLConnection) url.openConnection();
//huc.setConnectTimeout(5000);
huc.connect();
Log.i("aaa","bbbbb");
if(huc.getResponseCode()==200){
Log.i("aaa",""+huc.getResponseCode());
InputStream inputStream = huc.getInputStream();
int len=0;
byte[] b=new byte[1024];
StringBuilder sb=new StringBuilder();
while ((len=inputStream.read(b))!=-1){
sb.append(new String(b,0,len));
Log.i("aaa",sb.toString());
}
Log.i("aaab",sb.toString());
return sb.toString();
}
}catch (Exception e){
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
Gson gson=new Gson();
Foods foods = gson.fromJson(s, Foods.class);
// Log.i("tag",foods.getNewsList().toString());
newsList = foods.getData();
MyGridAdapter adapter=new MyGridAdapter(getContext(),newsList);
gv.setAdapter(adapter);
}
}
}
Fragment3类:
public class Fragment3 extends Fragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View inflate = inflater.inflate(R.layout.fragment_c, null);
return inflate;
}
}
Fragment4类:
public class Fragment4 extends Fragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View inflate = inflater.inflate(R.layout.fragment_e, null);
return inflate;
}
}
主函数MainActivity:
public class MainActivity extends AppCompatActivity {
private ViewPager vp;
RadioButton[] rbs=new RadioButton[4];
private RadioGroup rg;
List<Fragment> list=new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
vp = (ViewPager) findViewById(R.id.vp);
rg = (RadioGroup) findViewById(R.id.rg);
for (int i = 0; i < 4; i++) {
rbs[i]=(RadioButton)rg.getChildAt(i);
}
rbs[0].setChecked(true);
list.add(new Fragment1());
list.add(new Fragment2());
list.add(new Fragment3());
list.add(new Fragment4());
MyFramentAdapter adapter=new MyFramentAdapter(getSupportFragmentManager(),list);
vp.setAdapter(adapter);
rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (checkedId){
case R.id.rb_1:
vp.setCurrentItem(0);
break;
case R.id.rb_2:
vp.setCurrentItem(1);
break;
case R.id.rb_3:
vp.setCurrentItem(2);
break;
case R.id.rb_4:
vp.setCurrentItem(3);
break;
}
}
});
}
@Override
protected void onRestart() {
super.onRestart();
Log.i("tag","onRestart");
//vp.setCurrentItem(2);
}
}
MyAdapter类:
public class MyAdapter extends PagerAdapter {
List<View> list;
public MyAdapter(List<View> list) {
this.list = list;
}
@Override
public int getCount() {
return list.size();
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view==object;
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
container.addView(list.get(position));
return list.get(position);
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView(list.get(position));
}
}
MyFramentAdapter 类:
public class MyFramentAdapter extends FragmentStatePagerAdapter {
List<Fragment> list;
public MyFramentAdapter(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();
}
}
MyGridAdapter 类:
public class MyGridAdapter extends BaseAdapter{
Context context;
List<Foods.DataBean> list;
LayoutInflater inflater;
public MyGridAdapter(Context context, List<Foods.DataBean> list) {
this.context=context;
this.list=list;
inflater=LayoutInflater.from(context);
}
public int getCount() {
return list.size();
}
@Override
public Object getItem(int i) {
return list.get(i);
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
ViewHorld horld =null;
if (view==null)
{
horld=new ViewHorld();
view=inflater.inflate(R.layout.item,viewGroup,false);
horld.tv1= (TextView) view.findViewById(R.id.tv1);
horld.pic = (ImageView) view.findViewById(R.id.iv1);
view.setTag(horld);
}
else {
horld = (ViewHorld) view.getTag();
}
Log.i("ee",""+i);
horld.tv1.setText(list.get(i).getTitle());
Picasso.with(context).load(list.get(i).getPic()).into(horld.pic);
return view;
}
class ViewHorld{
TextView tv1;
ImageView pic;
}
}
MyHelper 类:
public class MyHelper extends SQLiteOpenHelper {
private static String NAME="shops.db";
private static int VERSION=1;
public MyHelper(Context context) {
super(context, NAME, null, VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("create table shop(_id integer primary key autoincrement,title varchar(50),image varchar(100),price varchar(20),flag boolean)");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
}
MyListAdapter 类:
public class MyListAdapter extends BaseAdapter {
List<Shop> list;
Context context;
public MyListAdapter(List<Shop> list, Context context) {
this.list = list;
this.context = context;
}
@Override
public int getCount() {
return list.size();
}
@Override
public Object getItem(int position) {
return list.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHorld horld =null;
if (convertView==null)
{
horld=new ViewHorld();
convertView= LayoutInflater.from(context).inflate(R.layout.item,parent,false);
horld.tv_title= (TextView) convertView.findViewById(R.id.c_title);
horld.tv_price= (TextView) convertView.findViewById(R.id.c_price);
horld.pic = (ImageView) convertView.findViewById(R.id.c_iv);
convertView.setTag(horld);
}
else {
horld = (ViewHorld) convertView.getTag();
}
horld.tv_title.setText(list.get(position).getTitle());
horld.tv_price.setText(list.get(position).getPrice());
Picasso.with(context).load(list.get(position).getImage()).into(horld.pic);
return convertView;
}
class ViewHorld{
TextView tv_title;
TextView tv_price;
ImageView pic;
}
}
MyReceiver 类:
public class MyReceiver extends BroadcastReceiver {
public MyReceiver() {
}
@Override
public void onReceive(Context context, Intent intent) {
NotificationManager manager=(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder compat=new NotificationCompat.Builder(context);
compat.setSmallIcon(R.mipmap.ic_launcher).setContentTitle("结算通知")
.setContentText("购买完成");
manager.notify(1,compat.build());
}
}
MyService 服务 类:
public class MyService extends Service {
public MyService() {
}
@Override
public IBinder onBind(Intent intent) {
// TODO: Return the communication channel to the service.
throw new UnsupportedOperationException("Not yet implemented");
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Intent intent1=new Intent("MyReceiver");
sendBroadcast(intent1);
return super.onStartCommand(intent, flags, startId);
}
}
Shop 类:
public class Shop {
private int id;
private String title;
private String image;
private String price ;
private boolean flag;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
public String getPrice() {
return price;
}
public void setPrice(String price) {
this.price = price;
}
public boolean isFlag() {
return flag;
}
public void setFlag(boolean flag) {
this.flag = flag;
}
}
ShopActivity 类:
public class ShopActivity extends AppCompatActivity {
private TextView s_title,s_price,s_fu,s_pin;
private ImageView iv;
private Foods.DataBean food;
MyHelper helper;
SQLiteDatabase db;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shop);
s_title = (TextView) findViewById(R.id.shop_title);
s_price = (TextView) findViewById(R.id.shop_price);
s_fu = (TextView) findViewById(R.id.shop_fu);
s_pin = (TextView) findViewById(R.id.shop_pin);
iv = (ImageView) findViewById(R.id.shop_iv);
food = ((Foods.DataBean) getIntent().getSerializableExtra("food"));
final String price = food.getId();
final String image = food.getPic();
final String title = food.getTitle();
helper=new MyHelper(this);
db=helper.getWritableDatabase();
s_fu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
s_pin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ContentValues cv=new ContentValues();
cv.put("title",title);
cv.put("image",image);
cv.put("price",price);
cv.put("flag",false);
long shop = db.insert("shop", null, cv);
if(shop>=0){
Toast.makeText(ShopActivity.this, "购物车添加成功", Toast.LENGTH_SHORT).show();
}
Intent in=new Intent(ShopActivity.this,CartActivity.class);
startActivity(in);
//finish();
}
});
s_title.setText(title);
s_price.setText(String.valueOf(price));
Picasso.with(this).load(image).into(iv);
}
}
WelcomeActivity 类:
public class WelcomeActivity extends AppCompatActivity {
private ViewPager vp;
List<View> list=new ArrayList<>();
private Button button;
RadioButton[] rbs=new RadioButton[3];
private RadioGroup rg;
SharedPreferences share;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
vp = (ViewPager) findViewById(R.id.vp);
rg = (RadioGroup) findViewById(R.id.rg);
share=getSharedPreferences("first",MODE_PRIVATE);
if(share.getBoolean("flag",false)){
Intent intent=new Intent(WelcomeActivity.this,MainActivity.class);
startActivity(intent);
finish();
return;
}
for (int i = 0; i < 3; i++) {
rbs[i]=((RadioButton) rg.getChildAt(i));
}
rbs[0].setChecked(true);
list.add(View.inflate(this,R.layout.fra1,null));
list.add(View.inflate(this,R.layout.fra2,null));
View inflate = View.inflate(this, R.layout.fra3, null);
button = ((Button) inflate.findViewById(R.id.btn));
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SharedPreferences.Editor edit = share.edit();
edit.putBoolean("flag",true);
edit.commit();
Intent intent=new Intent(WelcomeActivity.this,MainActivity.class);
startActivity(intent);
}
});
list.add(inflate);
MyAdapter adapter=new MyAdapter(list);
vp.setAdapter(adapter);
rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (checkedId){
case R.id.rb1:
vp.setCurrentItem(0);
break;
case R.id.rb2:
vp.setCurrentItem(1);
break;
case R.id.rb3:
vp.setCurrentItem(2);
break;
}
}
});
vp.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
rbs[position].setChecked(true);
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
}
@Override
protected void onDestroy() {
super.onDestroy();
vp.clearOnPageChangeListeners();
}
}
下面是布局
————————————————————————————————————————————————
activity_cart:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_cart"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="org.frxm.yuekao.CartActivity">
<LinearLayout
android:id="@+id/ll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/llb"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/ll_cb"
android:layout_width="40dp"
android:layout_height="match_parent"
android:orientation="vertical"></LinearLayout>
<ListView
android:id="@+id/lv"
android:layout_width="match_parent"
android:layout_height="match_parent"></ListView>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#C9C9C9"
android:layout_above="@+id/llb"/>
<RelativeLayout
android:id="@+id/llb"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true">
<CheckBox
android:id="@+id/c_all"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:text="全选"
android:layout_marginLeft="10dp"
/>
<TextView
android:id="@+id/c_total"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:text="合計:¥0"
android:gravity="center_vertical"
android:layout_marginRight="20dp"
android:layout_toLeftOf="@+id/btn_suan"/>
<Button
android:id="@+id/btn_suan"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:text="结算"
android:onClick="click"
android:background="#FF7800"
android:layout_alignParentRight="true"/>
</RelativeLayout>
</RelativeLayout>
activity_main:
<?xml version="1.0" encoding="utf-8"?>
<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">
<android.support.v4.view.ViewPager
android:id="@+id/vp"
android:layout_width="match_parent"
android:layout_height="match_parent"></android.support.v4.view.ViewPager>
<TextView
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#E1E1E1"
android:layout_above="@+id/rg"/>
<RadioGroup
android:id="@+id/rg"
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:background="#9D9D9D"
android:layout_alignParentBottom="true">
<RadioButton
android:id="@+id/rb_1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/home"
android:button="@null"
android:checked="true"
></RadioButton>
<RadioButton
android:id="@+id/rb_2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/weitao"
android:button="@null"
></RadioButton>
<RadioButton
android:id="@+id/rb_3"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/cart"
android:button="@null"
></RadioButton>
<RadioButton
android:id="@+id/rb_4"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/my"
android:button="@null"
></RadioButton>
</RadioGroup>
</RelativeLayout>
activity_main1:
<?xml version="1.0" encoding="utf-8"?>
<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">
<android.support.v4.view.ViewPager
android:id="@+id/vp"
android:layout_width="match_parent"
android:layout_height="match_parent"></android.support.v4.view.ViewPager>
<TextView
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#E1E1E1"
android:layout_above="@+id/rg"/>
<RadioGroup
android:id="@+id/rg"
android:layout_width="match_parent"
android:layout_height="80dp"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:background="@color/colorGray">
<RadioButton
android:id="@+id/rb1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:drawableTop="@drawable/home1"
android:text="首页"
android:background="@drawable/home_back"
android:gravity="center"
android:button="@null"
android:checked="true"
></RadioButton>
<RadioButton
android:id="@+id/rb2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:drawableTop="@drawable/home1"
android:background="@drawable/home_back"
android:text="首页"
android:gravity="center"
android:button="@null"
></RadioButton>
<RadioButton
android:id="@+id/rb3"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:drawableTop="@drawable/home1"
android:text="首页"
android:background="@drawable/home_back"
android:gravity="center"
android:button="@null"
></RadioButton>
<RadioButton
android:id="@+id/rb4"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:drawableTop="@drawable/home1"
android:text="首页"
android:background="@drawable/home_back"
android:gravity="center"
android:button="@null"
></RadioButton>
<RadioButton
android:id="@+id/rb5"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:drawableTop="@drawable/home1"
android:text="首页"
android:background="@drawable/home_back"
android:gravity="center"
android:button="@null"
></RadioButton>
</RadioGroup>
</RelativeLayout>
cativity_shop:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main3"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/lvlist1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/shop_iv"
android:layout_width="match_parent"
android:layout_height="240dp"
android:src="@mipmap/nv"/>
<TextView
android:id="@+id/shop_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15dp"
android:text="我的剑刃愿为您效劳"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="520 1314"/>
</LinearLayout>
<LinearLayout
android:id="@+id/lvlist2"
android:layout_below="@id/lvlist1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/shop_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30dp"
android:textColor="#c70811"
android:text="¥ 10000.00"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="快递:免运费"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="¥99999"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="售520件"/>
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/vw"
android:layout_below="@id/lvlist2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:textColor="#000"
android:layout_marginLeft="10dp"
android:text="规格详情"/>
<LinearLayout
android:id="@+id/lvlist3"
android:layout_below="@id/vw"
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_marginTop="20dp"
android:layout_height="wrap_content">
<TextView
android:layout_below="@id/lvlist2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:textColor="#000"
android:text="商品介绍"/>
<TextView
android:id="@+id/t1"
android:layout_below="@id/lvlist2"
android:layout_width="wrap_content"
android:layout_marginLeft="90dp"
android:layout_height="wrap_content"
android:textColor="#f5a607"
android:text="产品规格"/>
<TextView
android:layout_below="@id/lvlist2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="90dp"
android:textColor="#000"
android:text="宝贝评价"/>
</LinearLayout>
<TextView
android:id="@+id/t3"
android:layout_below="@id/lvlist3"
android:layout_width="match_parent"
android:background="#adb0b7"
android:layout_height="1dp" />
<LinearLayout
android:layout_below="@id/t3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_marginTop="5dp"
android:orientation="vertical"
android:layout_height="wrap_content">
<ImageView
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_marginLeft="5dp"
android:src="@mipmap/k1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="客服"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_marginTop="5dp"
android:orientation="vertical"
android:layout_height="wrap_content">
<ImageView
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_marginLeft="5dp"
android:src="@mipmap/k2"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="服务"/>
</LinearLayout>
<TextView
android:id="@+id/shop_fu"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_marginTop="15dp"
android:text="立马付款"
android:layout_marginLeft="30dp"
android:textColor="#ffffff"
android:gravity="center"
android:background="#f16305"/>
<TextView
android:id="@+id/shop_pin"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_marginTop="15dp"
android:text="一键拼单"
android:onClick="pd"
android:textColor="#ffffff"
android:gravity="center"
android:background="#cc0a0a"/>
</LinearLayout>
</RelativeLayout>
activity_welcome:
<?xml version="1.0" encoding="utf-8"?>
<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"
>
<android.support.v4.view.ViewPager
android:id="@+id/vp"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<RadioGroup
android:id="@+id/rg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:layout_marginBottom="20dp"
android:gravity="center">
<RadioButton
android:id="@+id/rb1"
android:layout_width="10dp"
android:layout_height="10dp"
android:button="@null"
android:background="@drawable/icon"
/>
<RadioButton
android:id="@+id/rb2"
android:layout_width="10dp"
android:layout_height="10dp"
android:button="@null"
android:background="@drawable/icon"
/>
<RadioButton
android:id="@+id/rb3"
android:layout_width="10dp"
android:layout_height="10dp"
android:button="@null"
android:background="@drawable/icon"
/>
</RadioGroup>
</RelativeLayout>
fra1:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/img1">
</LinearLayout>
fra2:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/img3">
</LinearLayout>
fra3:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/img4">
<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:text="进入"
android:layout_alignParentBottom="true"
android:layout_marginBottom="60dp"
android:layout_centerHorizontal="true"
android:background="#FF7300"
/>
</RelativeLayout>
fragment_a:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- TODO: Update blank fragment layout -->
<TextView
android:id="@+id/w"
android:layout_width="match_parent"
android:layout_height="30dp"
android:text="天猫TMALL"
android:background="#ce0613"
android:textColor="#fcfcfb"
android:textSize="20sp"
android:gravity="center"
android:layout_centerHorizontal="true"
/>
<LinearLayout
android:id="@+id/lv"
android:layout_width="match_parent"
android:layout_height="30dp"
android:gravity="center_vertical"
android:orientation="horizontal"
android:layout_below="@+id/w">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="全部"
android:layout_marginLeft="5dp"
android:textColor="#f7001d"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="女装"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="鞋包"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="居家"/>
<TextView
android:layout_width="wrap_content"
android:layout_marginLeft="10dp"
android:layout_height="wrap_content"
android:text="家电"/>
<TextView
android:layout_width="wrap_content"
android:layout_marginLeft="10dp"
android:layout_height="wrap_content"
android:text="数码家电"/>
<TextView
android:layout_width="wrap_content"
android:layout_marginLeft="10dp"
android:layout_height="wrap_content"
android:text="美食"/>
<TextView
android:layout_width="wrap_content"
android:layout_marginLeft="10dp"
android:layout_height="wrap_content"
android:text="内衣"/>
<TextView
android:layout_width="wrap_content"
android:layout_marginLeft="10dp"
android:layout_height="wrap_content"
android:text="男装"/>
<TextView
android:layout_width="wrap_content"
android:layout_marginLeft="10dp"
android:layout_height="wrap_content"
android:text="运动"/>
</LinearLayout>
<ImageView
android:id="@+id/iv"
android:layout_width="260dp"
android:layout_height="200dp"
android:src="@mipmap/iv1"
android:layout_below="@id/lv"/>
<ImageView
android:id="@+id/iv2"
android:layout_below="@id/lv"
android:layout_width="130dp"
android:src="@mipmap/i2"
android:layout_alignParentRight="true"
android:layout_height="200dp" />
<LinearLayout
android:id="@+id/lv2"
android:layout_below="@id/iv"
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal">
<TextView
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginLeft="10dp"
android:text="颜值控"
android:gravity="center"
android:background="#a7b0c2"/>
<TextView
android:layout_width="60dp"
android:layout_height="60dp"
android:gravity="center"
android:text="美食每刻"
android:layout_marginLeft="10dp"
android:background="#b41555"/>
<TextView
android:layout_width="60dp"
android:layout_height="60dp"
android:text="玩3C"
android:gravity="center"
android:layout_marginLeft="10dp"
android:background="#f28387"/>
<TextView
android:layout_width="60dp"
android:layout_height="60dp"
android:gravity="center"
android:text="浩宇优选"
android:layout_marginLeft="10dp"
android:background="#f4e2a2"/>
<TextView
android:layout_width="60dp"
android:layout_height="60dp"
android:gravity="center"
android:text="绿色家园"
android:layout_marginLeft="10dp"
android:background="#49ed7d"/>
</LinearLayout>
<LinearLayout
android:id="@+id/lv3"
android:layout_below="@id/lv2"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginTop="2dp"
android:orientation="horizontal">
<TextView
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginLeft="10dp"
android:text="Henry"
android:gravity="center"
android:background="#f1f29b"/>
<TextView
android:layout_width="60dp"
android:layout_height="60dp"
android:gravity="center"
android:text="家有萌宝"
android:layout_marginLeft="10dp"
android:background="#f5a885"/>
<TextView
android:layout_width="60dp"
android:layout_height="60dp"
android:text="品质家电"
android:gravity="center"
android:layout_marginLeft="10dp"
android:background="#a2f46f"/>
<TextView
android:layout_width="60dp"
android:layout_height="60dp"
android:gravity="center"
android:text="浩宇欧巴"
android:layout_marginLeft="10dp"
android:background="#e26efc"/>
<TextView
android:layout_width="60dp"
android:layout_height="60dp"
android:gravity="center"
android:text="浩宇欧巴"
android:layout_marginLeft="10dp"
android:background="#7fd3f4"/>
</LinearLayout>
<ImageView
android:id="@+id/iv3"
android:layout_below="@id/lv3"
android:layout_width="match_parent"
android:background="@mipmap/gg1"
android:layout_height="match_parent" />
</RelativeLayout>
fragment_b:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- TODO: Update blank fragment layout -->
<EditText
android:id="@+id/ed1"
android:layout_width="300dp"
android:layout_height="40dp"
android:background="#c6b5b6"
android:textSize="13dp"
android:layout_alignParentRight="true"
/>
<TextView
android:id="@+id/tv1"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@id/ed1"
android:layout_marginTop="2dp"
android:background="#aba5a5"/>
<LinearLayout
android:id="@+id/lv4"
android:layout_below="@id/tv1"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<LinearLayout
android:orientation="vertical"
android:layout_width="90dp"
android:layout_height="match_parent">
<Button
android:id="@+id/b1"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:background="#fafafa"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:text="美妆个护"/>
<Button
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_gravity="center_horizontal"
android:background="#fafafa"
android:layout_marginTop="10dp"
android:text="食品饮料"/>
<Button
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_gravity="center_horizontal"
android:background="#fafafa"
android:layout_marginTop="10dp"
android:text="服饰箱包"/>
<Button
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:background="#fafafa"
android:text="母婴玩具"/>
<Button
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:background="#fafafa"
android:text="家居生活"/>
<Button
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:background="#fafafa"
android:text="家用电器"/>
<Button
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_marginTop="10dp"
android:background="#fafafa"
android:layout_gravity="center_horizontal"
android:text="蔬果生鲜"/>
<Button
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_marginTop="10dp"
android:layout_gravity="center_horizontal"
android:background="#fafafa"
android:text="日用家纺"/>
<Button
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_marginTop="10dp"
android:layout_gravity="center_horizontal"
android:background="#fafafa"
android:text="手机数码"/>
</LinearLayout>
<TextView
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#90959e"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="40dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#cac2c2"/>
<GridView
android:id="@+id/gv"
android:layout_width="match_parent"
android:numColumns="3"
android:layout_height="match_parent"></GridView>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
fragment_c:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- TODO: Update blank fragment layout -->
</RelativeLayout>
fragment_e:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- TODO: Update blank fragment layout -->
</RelativeLayout>
item:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/iv1"
android:layout_width="80dp"
android:layout_height="80dp" />
<TextView
android:id="@+id/tv1"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"/>
</LinearLayout>
list_item:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/c_iv"
android:layout_width="80dp"
android:layout_height="80dp"/>
<TextView
android:id="@+id/c_title"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:gravity="center_vertical"
android:text="标题"
android:layout_toRightOf="@id/c_iv"/>
<TextView
android:id="@+id/c_price"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:gravity="center_vertical"
android:text="价格"
android:layout_toRightOf="@id/c_iv"
android:layout_below="@id/c_title"/>
<TextView
android:id="@+id/c_delete"
android:layout_width="wrap_content"
android:layout_height="80dp"
android:text="删除"
android:gravity="center_vertical"
android:layout_alignParentRight="true"/>
</RelativeLayout>