【发布时间】:2017-03-29 21:46:36
【问题描述】:
您好,我正在尝试创建包含两个按钮的对话框 [知道了! ] 和 [ 不要再显示我了
public boolean Show = false;
public void IntroSupport(){
Show = true;
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
ImageView image = new ImageView(this);
image.setImageResource(R.mipmap.ic_launcher);
builder.setIcon(R.mipmap.service)
.setTitle("Online Support :")
.setView(image)
.setMessage("Some text")
.setNegativeButton("GOT it!",null)
.setPositiveButton("Don't Show Me this Again", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
builder.setCancelable(false);
AlertDialog about = builder.create();
about.show();
TextView messageText = (TextView) about.findViewById(android.R.id.message);
messageText.setGravity(Gravity.CENTER);
Button nbutton = about.getButton(DialogInterface.BUTTON_NEGATIVE);
nbutton.setTextColor(Color.BLACK);
}
@Override
public void onPageSelected(int position) {
switch (position){
case 0:
getSupportActionBar().setTitle(Html.fromHtml("title :"+Pb));
tabLayout.getTabAt(0).setIcon(R.mipmap.ic1vrai);
tabLayout.getTabAt(1).setIcon(R.mipmap.ic__2vrai);
break;
case 1:
if(Show == false){
IntroSupport();
}
getSupportActionBar().setTitle(Html.fromHtml("("titl"+sus));
tabLayout.getTabAt(1).setIcon(R.mipmap.ic_2faux);
tabLayout.getTabAt(0).setIcon(R.mipmap.ic1faux);
break;
}
}
【问题讨论】:
标签: java android dialog android-alertdialog