AlertDialog输入数据并将数据显示在UI上
public void showInfo(TextView t, String title)
{
// 在对话框上显示的文本框 用于输入数据
final EditText edit = new EditText(this);
final TextView v = t;
AlertDialog.Builder builder = new Builder(this);
builder.setTitle(title);
builder.setView(edit);
builder.setPositiveButton("确定", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
// 将输入的数据显示在UI上
v.setText(edit.getText().toString());
}
});
builder.setNegativeButton("取消", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
}
});
builder.show();
}