为什么我的Android程序出来只有取消 这一个按钮,确定按钮被取消按钮盖住了?
publicclassMainActivityextendsAppCompatActivity{publicvoidsimple(Viewsource){AlertDia...
public class MainActivity extends AppCompatActivity {
public void simple(View source)
{
AlertDialog.Builder builder=new AlertDialog.Builder(this)
.setTitle("对话框").setIcon(R.drawable.aa).setMessage("简单的一个对话框/");
setPositiveButton(builder);
setNativeButton(builder).create().show();
}
private AlertDialog.Builder setPositiveButton(AlertDialog.Builder builder) {
return builder.setPositiveButton("queding", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
TextView show=(TextView)findViewById(R.id.show);
show.setText("单击了【确定】按钮");
}
});
}
private AlertDialog.Builder setNativeButton(AlertDialog.Builder builder)
{
return builder.setPositiveButton("quxiao", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
TextView show=(TextView)findViewById(R.id.show);
show.setText("单击了【取消】按钮");
}
});
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Button button=(Button)findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
simple(button);
}
});
} 展开
public void simple(View source)
{
AlertDialog.Builder builder=new AlertDialog.Builder(this)
.setTitle("对话框").setIcon(R.drawable.aa).setMessage("简单的一个对话框/");
setPositiveButton(builder);
setNativeButton(builder).create().show();
}
private AlertDialog.Builder setPositiveButton(AlertDialog.Builder builder) {
return builder.setPositiveButton("queding", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
TextView show=(TextView)findViewById(R.id.show);
show.setText("单击了【确定】按钮");
}
});
}
private AlertDialog.Builder setNativeButton(AlertDialog.Builder builder)
{
return builder.setPositiveButton("quxiao", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
TextView show=(TextView)findViewById(R.id.show);
show.setText("单击了【取消】按钮");
}
});
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Button button=(Button)findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
simple(button);
}
});
} 展开
2015-11-05
展开全部
setPositiveButton.....
更多追问追答
追问
什么意思?
追答
两个方法你仔细看
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询