CreatDialog(DIALOG_0);
@SuppressLint("ResourceAsColor")
public void CreatDialog(int id) {
AlertDialog.Builder builder = new AlertDialog.Builder(MainMenu.this);
switch (id) {
case DIALOG_0:
LinearLayout sc = new LinearLayout(this);
// sc.setBackgroundColor(R.color.white);
sc.setBackgroundResource(R.color.black);
sc.setOrientation(LinearLayout.VERTICAL);
// TextView txbg = new TextView(this);
// txbg.setBackgroundDrawable(getResources().getDrawable(R.drawable.title_top_bg));
// txbg.setText("");
// sc.addView(txbg);
TextView txtitle = new TextView(this);
txtitle.setText(" 联系京驰客服:");
// txtitle.setBackgroundColor(R.color.white);
txtitle.setBackgroundDrawable(getResources().getDrawable(R.drawable.title_top_bg));
txtitle.setTextSize(28);
sc.addView(txtitle);
LinearLayout sc2 = new LinearLayout(this);
sc2.setOrientation(LinearLayout.HORIZONTAL);
// 设置布局的高度
// LayoutParams ll = sc2.getLayoutParams();
// ll.height=100;
TextView txtu = new TextView(this);
txtu.setBackgroundDrawable(getResources().getDrawable(R.drawable.mainmenu_call));
txtu.setGravity(Gravity.CENTER);
sc2.addView(txtu);
TextView txphone = new TextView(this);
txphone.setText(" 01052489808");
txphone.setGravity(Gravity.CENTER);
txphone.setHeight(200);
txphone.setBackgroundColor(R.color.white);
txphone.setTextSize(24);
sc2.addView(txphone);
sc.addView(sc2);
// builder.setTitle("联系京驰客服:");
// builder.setMessage("\n 01052489808\n");//当前号码:\n
builder.setView(sc);
builder.setPositiveButton("拨号",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
Uri uriPhone = Uri.parse("tel:01052489808");
Intent it = new Intent(Intent.ACTION_DIAL, uriPhone);
startActivity(it);
}
});
builder.setNegativeButton("取消",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
}
});
break;
}
builder.create().show();
}
============================图示======================================
![bubuko.com,布布扣]()
自定义对话框
原文:http://blog.csdn.net/yangjianbo456/article/details/41746219