码迷,mamicode.com
首页 > 其他好文 > 详细

自定义对话框

时间:2014-12-05 14:20:52      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:对话框   android   

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,布布扣


自定义对话框

标签:对话框   android   

原文地址:http://blog.csdn.net/yangjianbo456/article/details/41746219

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!