Android 将文本设置为“编辑文本”`
我正在尝试在自定义AlertDialog中将文本设置为EditText。我正在使用以下代码Android 将文本设置为“编辑文本”`,android,Android,我正在尝试在自定义AlertDialog中将文本设置为EditText。我正在使用以下代码 ........ ........ ........ ........ case R.id.edit: LayoutInflater factory = LayoutInflater.from(this); final View textEntryView = factory.inflate(R.layout.editvslayout,
........
........
........
........
case R.id.edit:
LayoutInflater factory = LayoutInflater.from(this);
final View textEntryView = factory.inflate(R.layout.editvslayout,
null);
new AlertDialog.Builder(this)
.setTitle(
Messages.getString("OSListActivity.52") + item_cursor.getString(1)) //$NON-NLS-1$
.setView(textEntryView)
.setPositiveButton(Messages.getString("OSListActivity.53"), //$NON-NLS-1$
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {// TODO update path
// update desc
EditText evsname = (EditText) textEntryView
.findViewById(R.id.vsname);
EditText evsdesc = (EditText) textEntryView
.findViewById(R.id.vsdesc);
evsdesc.setText(folderdesc);
evsname.setText(foldername);
........
........
........
........
但是,文本没有显示出来。为什么?我怎样才能解决这个问题
编辑修复程序:
case R.id.edit:
LayoutInflater factory = LayoutInflater.from(this);
final View textEntryView = factory.inflate(R.layout.editvslayout,
null);
final EditText evsname = (EditText) textEntryView
.findViewById(R.id.vsname);
final EditText evsdesc = (EditText) textEntryView
.findViewById(R.id.vsdesc);
evsdesc.setText(folderdesc);
evsname.setText(foldername);
new AlertDialog.Builder(this)
.setTitle(
Messages.getString("OSListActivity.52") + item_cursor.getString(1)) //$NON-NLS-1$
.setView(textEntryView)
.setPositiveButton(Messages.getString("OSListActivity.53"), //$NON-NLS-1$
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
// code here
}
编辑文本是否正确可见。。。?此外,根据您的代码,编辑文本将在单击肯定按钮时显示文本。但是,单击肯定按钮后,alreat对话框将自动关闭。您可以回答您的问题,而不是编辑,也可以接受您的答案,以便其他人知道此问题的答案,并且您也因此获得了分数……:@我知道希拉加,但分数被高估了