我已经EditText
动态地创建了视图。我还创建了一个dialog
带有EditText
视图的警报。现在我应该将在警报对话框中键入的文本获取到动态生成的EditText
. 请帮我..
@Override
public void onClick(View v) {
EditText input = new EditText(this);
Context Context = this;
AlertDialog Alert=new AlertDialog.Builder(Context).setTitle("Add Field").setMessage("Proceed").setView(input).setPositiveButton("Yes",new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "You clicked on Yes", Toast.LENGTH_LONG).show();
}
}).setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
dialog.cancel();
Toast.makeText(getApplicationContext(), "You clicked on No", Toast.LENGTH_LONG).show();
}
}).show();
LinearLayout linearLayout = (LinearLayout)findViewById(R.id.editTextGroupLayout);
EditText editTextView = new EditText(this);
editTextView.setGravity(Gravity.CENTER);
LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
editTextView.setLayoutParams(params);
editTextView.setHint("Enter Field ");
linearLayout.addView(editTextView);
if(v.getId()==R.id.button_selectoptionsback){
Intent a=new Intent(this,Admin.class);
this.startActivity(a);
}
}
}