自定义AlertDialog_选项格式

 
  

                                                     效果如图

private String[] newtan = new String[] { "删除联系人","添加联系人","拨打电话","详情"};

new AlertDialog.Builder(ContactsActivity.this).setTitle("信息选项")

.setItems(newtan , new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog, int which) {
switch (which) {
case 0://删除联系人
break;
case 1://添加联系人
dismissDialog(1);
Intent intent2 = new Intent(ContactsActivity.this,AddManActivity.class);
Toast.makeText(ContactsActivity.this, (CharSequence) map.get("phoneNumber"), Toast.LENGTH_SHORT).show();
startActivity(intent2);
break;
case 2://拨打电话
intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:"
+ map.get("phoneNumber")));
ContactsActivity.this.startActivity(intent);
break;
case 3://详情
intent.setClass(ContactsActivity.this,ContactDesActivity.class);
Toast.makeText(ContactsActivity.this, (CharSequence) map.get("phoneNumber"), Toast.LENGTH_SHORT).show();
ContactsActivity.this.startActivity(intent);
break;
}
}
}).show();

你可能感兴趣的:(Android)