商品细节
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("加入失败");
}
}
};
}
以上是内存溢出为你收集整理的STD二手图书交流平台团队博客全部内容,希望文章能够帮你解决STD二手图书交流平台团队博客所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)