我想从应该在对话框中的位置自动完成片段中获取价值,并希望在“编辑”文本中设置搜索到的位置。
public class MainActivity extends FragmentActivity
{
final Context context = this;
private EditText editText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
editText = (EditText) findViewById(R.id.editText);
editText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
openDialog();
}
});
}
public void openDialog()
{
LayoutInflater li = LayoutInflater.from(context);
View promptsView = li.inflate(R.layout.activity_get_value, null);
android.app.AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
alertDialogBuilder.setView(promptsView);
AlertDialog alertDialog = alertDialogBuilder.create();
// show it
alertDialog.show();
}
}