• STD二手图书交流平台团队博客-商品属性与操作


    更新完善商品属性 使得商品信息更加全面 形象更加立体

    便于买家进行判断和分析

    实现对商品的操作 加入购物车以及购买支付的功能

    遇到问题:商品支付不能跳转 并未得到权限

    商品细节

    package com.example.secondhand;

    import android.app.AlertDialog;
    import android.content.DialogInterface;
    import android.content.Intent;
    import android.graphics.Bitmap;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.ImageView;
    import android.widget.TextView;

    import androidx.appcompat.app.AppCompatActivity;


    import static com.example.secondhand.UiUtils.getContext;


    //商品细节显示

    public class DetailActivity extends AppCompatActivity {
    ImageView ivGoodsPic;
    TextView tvGoodsName;
    TextView tvGoodsPrice;
    TextView tvGoodsCategory;
    TextView tvGoodsPhone;
    TextView tvGoodsTime;
    Button btnAddPurchase;
    Button btnAddBuycar;
    TextView tvLiuyan;
    String id;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_detail);
    ivGoodsPic = findViewById(R.id.ivGoodsPic);
    tvGoodsName = findViewById(R.id.tvGoodsName);
    tvGoodsPrice = findViewById(R.id.tvGoodsPrice);
    tvGoodsCategory = findViewById(R.id.tvGoodsCategory);
    tvGoodsPhone = findViewById(R.id.tvGoodsPhone);
    tvGoodsTime = findViewById(R.id.tvGoodsTime);
    btnAddBuycar = findViewById(R.id.btnAddBuycar);
    btnAddPurchase = findViewById(R.id.btnAddPurchase);
    tvLiuyan = findViewById(R.id.tvLiuyan);
    Bundle b = getIntent().getExtras();
    if (b != null) {
    Bitmap bitmap = b.getParcelable("bitmap");
    ivGoodsPic.setImageBitmap(bitmap);
    tvGoodsName.setText("商品名称:"+b.getString("商品名称:"));
    tvGoodsPrice.setText("商品价格:"+b.getString("商品价格:"));
    tvGoodsCategory.setText("商品分类:"+b.getString("商品分类:")+ "¥");
    tvGoodsPhone.setText("联系电话:"+b.getString("联系电话:"));
    tvGoodsTime.setText("发布时间:"+b.getString("发布时间:"));
    btnAddBuycar.setOnClickListener(listener1);
    btnAddPurchase.setOnClickListener(listener2);
    tvLiuyan.setOnClickListener(listener3);
    id=b.getString("goodsId");
    }
    }
    private View.OnClickListener listener3= new View.OnClickListener(){
    @Override
    public void onClick(View v) {
    Bundle b = getIntent().getExtras();
    Intent intent = new Intent(getContext(), CommentActivity.class);
    intent.putExtras(b);
    startActivity(intent);
    }
    };

    private View.OnClickListener listener2= new View.OnClickListener(){
    @Override
    public void onClick(View v) {
    String goodsId = id;
    int checkId;
    System.out.println("goodsId : " + goodsId);
    int raw = ProductDao.getInstance().updateGoodsBuyed(goodsId);
    if (raw > 0){
    showDropOutDialog();
    }else {
    UiUtils.toast("购买失败!");
    }
    }
    };

    private void showDropOutDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("提示");
    builder.setMessage("请确认是否支付?");
    builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
    UiUtils.toast("支付成功");
    }
    });
    builder.setNegativeButton("取消",new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
    dialog.dismiss();
    }
    });
    AlertDialog alertDialog = builder.create();
    alertDialog.show();
    }

    private View.OnClickListener listener1 = new View.OnClickListener(){
    @Override
    public void onClick(View v) {
    //UiUtils.toast("已加入购物车");
    String goodsId1 = id;
    System.out.println("goodsId : " + goodsId1);
    int raw1 = ProductDao.getInstance().updateGoodsAddBuyCar(goodsId1);
    if (raw1 > 0){
    UiUtils.toast("已加入购物车");
    }else {
    UiUtils.toast("加入失败");
    }
    }
    };
    }

     

  • 相关阅读:
    (KMP Next的运用) Period II -- fzu -- 1901
    (字典树)How many--hdu--2609
    (KMP 最大表示最小表示)String Problem -- hdu-- 3374
    (KMP 暴力)Corporate Identity -- hdu -- 2328
    (KMP 扩展)Clairewd’s message -- hdu -- 4300
    (KMP 字符串处理)Substrings -- hdu -- 1238
    (KMP)Count the string -- hdu -- 3336
    JQuery弹出窗口小插件ColorBox
    jquery promot
    C#
  • 原文地址:https://www.cnblogs.com/Yforever/p/14912940.html
Copyright © 2020-2023  润新知