我的订单

package com.example.fangjingdong.view.activity;

import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.example.fangjingdong.R;
import com.example.fangjingdong.view.fragment.FragmentDaiZhiFu;
import com.example.fangjingdong.view.fragment.FragmentQuanBu;
import com.example.fangjingdong.view.fragment.FragmentYiQuXiao;
import com.example.fangjingdong.view.fragment.FragmentYiZhiFu;

public class MyDingDan extends AppCompatActivity implements View.OnClickListener {
    private ImageView detail_image_back;
    private ImageView detail_share;
    private RadioGroup radio_group;
    private ImageView san_dian_pop;
    private PopupWindow popupWindow;
    private TextView pop_dai_pay;
    private TextView pop_already_pay;
    private TextView pop_cancel;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_ding_dan);
        detail_image_back = (ImageView) findViewById(R.id.detail_image_back);
        radio_group = (RadioGroup) findViewById(R.id.radio_group);
        san_dian_pop = (ImageView) findViewById(R.id.san_dian_pop);

        detail_image_back.setOnClickListener(this);
        san_dian_pop.setOnClickListener(this);

        initPopUpWindown();

        int flag = getIntent().getIntExtra("flag", -1);
        if (flag == -1) {

            getSupportFragmentManager().beginTransaction().replace(R.id.frame_content,new FragmentQuanBu()).commit();
        }else {
            //如果从fragemnt跳转过来 需要展示自己的页面
            if (flag == 1) {//待支付
                radio_group.check(R.id.radio_02);
                getSupportFragmentManager().beginTransaction().replace(R.id.frame_content,new FragmentDaiZhiFu()).commit();
            }else if (flag == 2) {//已支付
                radio_group.check(R.id.radio_03);
                getSupportFragmentManager().beginTransaction().replace(R.id.frame_content,new FragmentYiZhiFu()).commit();
            }else if (flag == 3) {//已取消
                radio_group.check(R.id.radio_04);
                getSupportFragmentManager().beginTransaction().replace(R.id.frame_content,new FragmentYiQuXiao()).commit();
            }
        }

        radio_group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int id) {
                switch (id) {
                    case R.id.radio_01://全部
                        getSupportFragmentManager().beginTransaction().replace(R.id.frame_content,new FragmentQuanBu()).commit();
                        break;
                    case R.id.radio_02://待支付
                        getSupportFragmentManager().beginTransaction().replace(R.id.frame_content,new FragmentDaiZhiFu()).commit();
                        break;
                    case R.id.radio_03://已支付
                        getSupportFragmentManager().beginTransaction().replace(R.id.frame_content,new FragmentYiZhiFu()).commit();
                        break;
                    case R.id.radio_04://已取消
                        getSupportFragmentManager().beginTransaction().replace(R.id.frame_content,new FragmentYiQuXiao()).commit();
                        break;
                }
            }
        });

    }

    private void initPopUpWindown() {
        View view= View.inflate(MyDingDan.this,R.layout.order_pop_layout,null);
        popupWindow = new PopupWindow(view, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        popupWindow.setFocusable(true);
        popupWindow.setTouchable(true);
        popupWindow.setOutsideTouchable(true);
        popupWindow.setBackgroundDrawable(new BitmapDrawable());

        //找到控件
        pop_dai_pay = view.findViewById(R.id.pop_dai_pay);
        pop_already_pay = view.findViewById(R.id.pop_already_pay);
        pop_cancel = view.findViewById(R.id.pop_cancel);

        pop_dai_pay.setOnClickListener(this);
        pop_already_pay.setOnClickListener(this);
        pop_cancel.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.detail_image_back:
                finish();
                break;
            case R.id.san_dian_pop://弹出pop
                //判断一下当前radioGroup选中了哪一个RadioButton...设置展示的背景颜色
                int checkedRadioButtonId = radio_group.getCheckedRadioButtonId();
                switch (checkedRadioButtonId) {
                    case R.id.radio_02://待支付
                        pop_dai_pay.setBackgroundColor(Color.BLUE);
                        pop_already_pay.setBackgroundColor(Color.WHITE);
                        pop_cancel.setBackgroundColor(Color.WHITE);
                        break;
                    case R.id.radio_03://已支付
                        pop_dai_pay.setBackgroundColor(Color.WHITE);
                        pop_already_pay.setBackgroundColor(Color.BLUE);
                        pop_cancel.setBackgroundColor(Color.WHITE);
                        break;
                    case R.id.radio_04://已取消
                        pop_dai_pay.setBackgroundColor(Color.WHITE);
                        pop_already_pay.setBackgroundColor(Color.WHITE);
                        pop_cancel.setBackgroundColor(Color.BLUE);
                        break;
                }

                popupWindow.showAsDropDown(san_dian_pop);

                break;
            case R.id.pop_dai_pay://待支付
                radio_group.check(R.id.radio_02);
                getSupportFragmentManager().beginTransaction().replace(R.id.frame_content,new FragmentDaiZhiFu()).commit();
                popupWindow.dismiss();
                break;
            case R.id.pop_already_pay://已支付
                radio_group.check(R.id.radio_03);
                getSupportFragmentManager().beginTransaction().replace(R.id.frame_content,new FragmentYiZhiFu()).commit();
                popupWindow.dismiss();
                break;
            case R.id.pop_cancel://已取消
                radio_group.check(R.id.radio_04);
                getSupportFragmentManager().beginTransaction().replace(R.id.frame_content,new FragmentYiQuXiao()).commit();
                popupWindow.dismiss();
                break;
        }
    }
}


布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.example.fangjingdong.view.activity.MyDingDan">
    <RelativeLayout
        android:id="@+id/detai_relative"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <ImageView
            android:id="@+id/detail_image_back"
            android:padding="5dp"
            android:src="@drawable/leftjiantou"
            android:layout_width="40dp"
            android:layout_height="40dp" />

        <TextView
            android:layout_centerInParent="true"
            android:text="我的订单"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <ImageView
            android:id="@+id/san_dian_pop"
            android:padding="5dp"
            android:layout_alignParentRight="true"
            android:src="@drawable/sandian"
            android:layout_width="40dp"
            android:layout_height="40dp" />

    </RelativeLayout>

    <RadioGroup
        android:id="@+id/radio_group"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="40dp">

        <RadioButton
            android:id="@+id/radio_01"
            android:checked="true"
            android:button="@null"
            android:gravity="center"
            android:textColor="@color/radio_text_color"
            android:text="全部"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="match_parent" />

        <RadioButton
            android:id="@+id/radio_02"
            android:button="@null"
            android:gravity="center"
            android:textColor="@color/radio_text_color"
            android:text="待支付"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="match_parent" />

        <RadioButton
            android:id="@+id/radio_03"
            android:button="@null"
            android:gravity="center"
            android:textColor="@color/radio_text_color"
            android:text="已支付"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="match_parent" />

        <RadioButton
            android:id="@+id/radio_04"
            android:button="@null"
            android:gravity="center"
            android:textColor="@color/radio_text_color"
            android:text="已取消"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="match_parent" />

    </RadioGroup>

    <FrameLayout
        android:id="@+id/frame_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    </FrameLayout>

</LinearLayout>
好的,我可以为您提供一个简单的订单页面的Bootstrap代码。以下是一个示例代码,您可以根据您的需求进行更改和调整。 ```html <!DOCTYPE html> <html lang="en"> <head> <title>订单页面</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h2>订单</h2> <div class="row"> <div class="col-md-8"> <form> <div class="form-group"> <label for="name">姓名:</label> <input type="text" class="form-control" id="name" placeholder="请输入您的姓名" name="name"> </div> <div class="form-group"> <label for="email">邮箱:</label> <input type="email" class="form-control" id="email" placeholder="请输入您的邮箱" name="email"> </div> <div class="form-group"> <label for="phone">电话:</label> <input type="tel" class="form-control" id="phone" placeholder="请输入您的电话" name="phone"> </div> <div class="form-group"> <label for="address">地址:</label> <input type="text" class="form-control" id="address" placeholder="请输入您的地址" name="address"> </div> <div class="form-group"> <label for="product">产品:</label> <input type="text" class="form-control" id="product" placeholder="请输入您要购买的产品" name="product"> </div> <div class="form-group"> <label for="quantity">数量:</label> <input type="number" class="form-control" id="quantity" placeholder="请输入您要购买的数量" name="quantity"> </div> <div class="form-group"> <label for="message">留言:</label> <textarea class="form-control" rows="5" id="message" name="message"></textarea> </div> <button type="submit" class="btn btn-default">提交订单</button> </form> </div> <div class="col-md-4"> <h3>订单总览</h3> <table class="table table-striped"> <thead> <tr> <th>产品</th> <th>数量</th> <th>价格</th> </tr> </thead> <tbody> <tr> <td>产品名称</td> <td>1</td> <td>$100.00</td> </tr> <tr> <td>产品名称</td> <td>2</td> <td>$200.00</td> </tr> <tr> <td>产品名称</td> <td>3</td> <td>$300.00</td> </tr> </tbody> </table> <p>总价: $600.00</p> </div> </div> </div> </body> </html> ``` 这个订单页面由一个表单和一个订单总览表格组成。您可以将表单中的字段更改为您需要的字段,并根据需要更新订单总览表格。希望这可以帮助到您!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值