我想根据 for 循环生成编辑框的数量,并带有一个按钮,该按钮必须调用将用户输入数据处理到编辑框中的方法。
据我所知,我不能使用警报对话框,因为它们是异步的并且不会等待用户响应,我可能会使用上面提到的方法并查看行为。并且需要建议和建议。下面的代码可能会给出更多的想法。
for(int x=0;x<vars.size();x++)
{
String get_var=vars.get(x).toString();//get the first item from array
replace(get_var,temp_t);//send the get_var to replace method
}
替换方法的想法是
replace(String get_var,String temp_t)
{
String y=(user input from the textbox, which has to be created dynamically)
if(button pressed) //created dynamically
process(y,temp_t)
}
请建议是否有其他更好的解决方法,然后我认为应该像消除按钮并直接处理[更新]
for(int x=0;x<vars.size();x++)
{
String get_var=vars.get(x).toString();
get_vals_for_xy(get_var, temp_t);
}
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}//end of oncreate method
public void get_vals_for_xy(String get_var,String[][] temp_t) {
System.out.println("value of get_var is " + get_var);
AlertDialog.Builder alert = new AlertDialog.Builder(this);
final EditText edittext = new EditText(this);
alert.setMessage("value is"+get_var);
alert.setTitle("Title");
alert.setView(edittext);
alert.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String to_replace = edittext.getText().toString();
show(to_replace);
Toast.makeText(AssignValandFacts.this, to_replace, Toast.LENGTH_SHORT).show();
}
});
alert.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
});
alert.show();
}