button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle(“请输入” +
“城市名称:”);
builder.setIcon(R.mipmap.shezhi1).setView(editText);
String ad = editText.getText().toString();
StringBuilder aaa = new StringBuilder(ad);
String abc = aaa.toString();
builder.setNegativeButton(“取消”, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}).setPositiveButton(“确定”, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
builder.create().show();
button.setText(abc);
本人试了setText()不行 拜谢高手解答
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle(“请输入” +
“城市名称:”);
builder.setIcon(R.mipmap.shezhi1).setView(editText);
String ad = editText.getText().toString();
StringBuilder aaa = new StringBuilder(ad);
String abc = aaa.toString();
builder.setNegativeButton(“取消”, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}).setPositiveButton(“确定”, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
builder.create().show();
button.setText(abc);
本人试了setText()不行 拜谢高手解答
解决方案
80
很明显会报空指针,原因是你的控件没有正确引用