我在片段活动中使用了带标题的警告对话框。我在单独的类中创建了警告对话框。
当我点击警告对话框中的按钮???
时,我必须更新标题名称下面显示警告对话框代码
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();
}
}
答案 0 :(得分:1)
而不是使用
builder.show();
使用此
AlertDialog alert = builder.create();
alert.show();
答案 1 :(得分:1)
在对话框类中使用以下代码:
静态 AlertDialog警告;
alert = builder.create(); alert.show();
然后在Fragment活动中使用以下代码
ViewCartDialog.alert.setTitle("");