前言:话不多说,先上图
从上面的图片可以看出该界面由余额信息和流式布局的订单信息以及确认支付三部分组成,代码如下:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:id="@+id/rl_top" android:background="@drawable/text_bg" > <ImageView android:id="@+id/back" android:layout_marginTop="27dp" android:layout_width="wrap_content" android:layout_height="@dimen/dp_45" android:paddingLeft="@dimen/dp_15" android:src="@mipmap/back_white" /> <TextView android:id="@+id/tv" android:layout_width="match_parent" android:layout_height="@dimen/dp_72" android:gravity="center" android:paddingTop="27dp" android:text="我的钱包" android:textColor="@color/white" android:textSize="@dimen/text_14_sp" /> <TextView android:id="@+id/tv_ddjl" android:layout_width="wrap_content" android:layout_height="@dimen/dp_72" android:paddingTop="27dp" android:layout_alignParentRight="true" android:gravity="center" android:text="充值记录" android:textColor="@color/white" android:textSize="@dimen/text_16_sp" /> <TextView android:id="@+id/tv_zhye" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/tv" android:gravity="center" android:paddingTop="@dimen/dp_15" android:text="账户余额" android:textColor="@color/white" android:textSize="@dimen/text_14_sp" /> <TextView android:id="@+id/rb" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/tv_zhye" android:gravity="center" android:paddingTop="10dp" android:text="R币:327" android:textColor="@color/white" android:textSize="@dimen/text_18_sp" /> <TextView android:id="@+id/rd" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/rb" android:gravity="center" android:paddingTop="10dp" android:text="R点:80(期限R点:800)" android:textColor="@color/white" android:textSize="@dimen/text_14_sp" /> <TextView android:id="@+id/rddh" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/rd" android:gravity="center" android:paddingTop="10dp" android:text="R点兑换" android:textColor="@color/white" android:textSize="@dimen/text_18_sp" android:paddingBottom="@dimen/dp_20"/> </RelativeLayout> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/tv_rbcz" android:text="R币充值" android:layout_below="@id/rl_top" android:layout_marginTop="@dimen/dp_10" android:layout_marginLeft="@dimen/dp_10"/> <com.example.administrator.parentproject.utils.ChooseRbLayout android:id="@+id/choose_money" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="@dimen/dp_5" android:layout_below="@id/tv_rbcz" android:horizontalSpacing="17dp" android:numColumns="4" android:verticalSpacing="@dimen/dp_20"> </com.example.administrator.parentproject.utils.ChooseRbLayout> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/other" android:text="其他" android:layout_below="@id/choose_money" android:layout_centerHorizontal="true" android:textSize="@dimen/sp_16"/> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:id="@+id/ll" android:layout_below="@id/other"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/dp_10" android:text="支付金额:"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/red" android:id="@+id/zfje" android:text="10元"/> </LinearLayout> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/pay" android:layout_below="@id/ll" android:background="@drawable/yjbiankuang_red_2" android:layout_margin="@dimen/dp_20" android:textColor="@color/white" android:text="确认支付"/> </RelativeLayout>
其中,最主要的就是订单的处理,由于手机端界面有限无法将所有的订单展现,因此我们只显示8个订单,点击其他后查看完整的订单信息,相关代码如下:
private void initMoneyChoose() { if(mData.size()>7){ ArrayList<String> mData1 = new ArrayList<>(); for (int i=0;i<8;i++){ mData1.add(mData.get(i)); } rbLayout.setMoneyData(mData1); //设置默认选中项 rbLayout.setDefaultPositon(0); //金额选择监听 rbLayout.setOnChoseMoneyListener(new ChooseRbLayout.onChoseMoneyListener() { @Override public void chooseMoney(int position, boolean isCheck, String moneyNum) { if (isCheck) { zfje.setText(mList.get(position).getRefill_type() + "元"); target = position; } else { } } }); other.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(WalletActivity.this,MoreOrderActivity.class); Bundle bundle = new Bundle(); intent.putExtra("mData",mData); intent.putExtra("target",target); startActivityForResult(intent,101); } }); }else { rbLayout.setMoneyData(mData); //设置默认选中项 rbLayout.setDefaultPositon(0); //金额选择监听 rbLayout.setOnChoseMoneyListener(new ChooseRbLayout.onChoseMoneyListener() { @Override public void chooseMoney(int position, boolean isCheck, String moneyNum) { if (isCheck) { zfje.setText(mList.get(position).getRefill_type() + "元"); target = position; } else { } } }); other.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Toast.makeText(MyApplication.getContextObject(),"暂无更多",Toast.LENGTH_SHORT).show(); } }); } }
其他订单界面如下: