首页 > 其他 > 详细

自定义对话框

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!