先生,我将创建带有一些editText 字段的自定义对话框,其中Listview 的选定项的值被绘制并设置为EditText 的值。
但是当涉及到执行时,它总是变为 null 如下
08-29 18:08:06.211: D/dalvikvm(10652): GC_FOR_ALLOC freed 219K, 6% free 21317K/22663K, paused 11ms, total 11ms
08-29 18:08:07.811: D/debug getCovreage Address(10652): 15
08-29 18:08:07.831: D/txtB(10652): null
08-29 18:08:07.831: D/txtFt(10652): null
08-29 18:08:07.831: D/txtFr(10652): null
您能告诉我如何在自定义 editText 中初始化 editText ,设置值并获取 EditText 的值吗?
coverageList.setBackgroundColor(Color.WHITE);
coverageList.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
curservid = resultList.get(arg2).get("Block").toString();
Log.d("debug getCovreage Address" , curservid);
final Dialog dialog = new Dialog(EOrderCheckCoverage.this);
dialog.setContentView(R.layout.custom_coverage_open_order);
dialog.setTitle("Open Order");
// set the custom dialog components - text, image and button
final EditText txtB = (EditText)findViewById(R.id.txtBlock);
Log.d("txtB" , String.valueOf(txtB));
final EditText txtFt = (EditText)findViewById(R.id.txtFlat);
Log.d("txtFt" , String.valueOf(txtFt));
final EditText txtFr = (EditText)findViewById(R.id.txtBlockFloor);
Log.d("txtFr" , String.valueOf(txtFr));
Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK);
// if button is clicked, close the custom dialog
dialogButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String a = txtB.getText().toString();
String b = txtFt.getText().toString();
String c = txtFr.getText().toString();
dialog.dismiss();
Toast.makeText(EOrderCheckCoverage.this, a + " " + b + " " + c, Toast.LENGTH_LONG).show();
}
});
dialog.show();
}
});