问题描述
我使用下面的代码在android应用中获取用户输入.它运行正常,但经过几次尝试我发现的是那样.下面的方法从for循环中调用以获取不同的值.
i used the code below to get user input in android app. it runs fine but what i found after several attempts is that.the method below is called from a for loop to get different values.
-
代码以相反的顺序接受输入,即它必须先获取x的值,然后获取y的值.在应用程序上时,系统要求我输入y的值,然后输入x.
The code takes input in reverse order i.e it has to take value for x and then y. while on the app i am asked to enter value of y and then x.
它不等待用户输入,它显示对话框,但继续运行整个程序.因为当我输入任何值时都不会做任何更改.
it doesnot wait for the user input it shows the dialogue box but keeps on running the whole program. as when i enter any value doesnt make any changes as it has to do.
我认为对话框的反向顺序也是出于相同的原因,即第二个对话框与第一个对话框重叠.
what i believe is that the reverse order of dialogue boxes is also from the same reason that the second dialogue box overlaps the first one.
如何使它停止,除非用户输入任何数据然后继续前进?同样,当我从代码中的编辑框中删除final时,它给出了错误,请使用remove视图,因为这个孩子已经有一个父级了.
how do i make it stop unless user enter any data and then move forward?also when i remove final from the editbox in the code, it gives error the please use remove view because this child already has a parent etc.
下面提供了代码
void var_init(String to_match,String[][] temp) {
String t_match=to_match;
//problem in the below line
AlertDialog.Builder builder = new AlertDialog.Builder(RuleEngine.this);
builder.setTitle("Enter Value for"+t_match);
// Set up the input
final EditText input = new EditText(RuleEngine.this);
builder.setView(input);
// Set up the buttons
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
t_replace = input.getText().toString();
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
builder.show();
推荐答案
它是因为对话框每次迭代都相互重叠.实际上,x排在第一位,但与y对话框重叠.一种异步行为,尝试找到其他方法.
Its becasue the dialogue boxes overlaps each other with every iteration. in reality the x is coming first but overlapped by the y dialogue box. an as async behaviour try to find other way around.
这篇关于用户使用for循环和提示对话框输入的内容显示了不同的行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!