为什么我的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.....
更多追问追答
追问
什么意思?
追答
两个方法你仔细看
微测检测5.10
2023-05-10 广告
2023-05-10 广告
您好!建议咨 深圳市微测检测有限公司,已建立起十余个专业实验室,企业通过微测检测就可以获得一站式的测试与认 证解决方案;(EMC、RF、MFi、BQB、QI、USB、安全、锂电池、快充、汽车电子EMC、汽车手机互 联、语音通话质量),认证遇...
点击进入详情页
本回答由微测检测5.10提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询