gpt4 book ai didi

android - 在android中更新警报对话框标题

转载 作者:行者123 更新时间:2023-11-29 20:57:32 25 4
gpt4 key购买 nike

我在 fragment Activity 中使用了带有标题的警报对话框。我在单独的类中创建了警报对话框。

当我单击警告对话框中的按钮时,我必须更新标题名称???

下面是警告对话框代码

public  class ViewCartDialog 
{
Activity activity;
Cursor cursor;
public static AlertDialog.Builder builder;
public ViewCartDialog(Activity activity)
{
this.activity=activity;
cartDialog();
}
public void cartDialog()
{
// TODO Auto-generated method stub
builder = new AlertDialog.Builder(activity);
// builder.setIcon(R.drawable.shopping_cart);
cursor = DBCatalog.getCursor();
builder.setTitle("My Carts"+"("+cursor.getCount()+")");
LayoutInflater adbInflater = LayoutInflater.from(activity);
View cartview = adbInflater.inflate(R.layout.cart_list, null);
final EditText custcode=(EditText) cartview.findViewById(R.id.cust_codefield);
final EditText custname=(EditText) cartview.findViewById(R.id.cust_namefield);
custcode.setOnTouchListener(new DrawableClickListener.RightDrawableClickListener(
custcode) {
@Override
public boolean onDrawableClick() {
new Customer(activity,custcode,custname);
return true;

}

});
ListView cart_lv=(ListView) cartview.findViewById(R.id.cart_list);
CartAdapter cartadapter=new CartAdapter(activity, R.layout.cart_listitem, cursor);
cart_lv.setAdapter(cartadapter);
builder.setView(cartview);
builder.setNegativeButton("cancel",
new DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});

builder.setPositiveButton("Place Order",
new DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface dialog, int which) {

}
});
builder.show();
}
}

最佳答案

在对话框类中使用以下代码:

静态 AlertDialog 警报;

alert = builder.create(); alert.show();

然后在Fragment activity中使用如下代码

ViewCartDialog.alert.setTitle("");

关于android - 在android中更新警报对话框标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27202741/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com