以下是我的android程序中的方法,当被调用时,它被发送到无限循环中。任何帮助将不胜感激。如果你需要堆栈跟踪来解决这个问题,它可能是不可能的,因为一旦这个无限循环开始,它就是大约30,000行。
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Enter a Title:");
final EditText input = new EditText(this);
input.setInputType(InputType.TYPE_CLASS_TEXT);
builder.setView(input);
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
inputtext = input.getText().toString();
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
builder.show();
try {
Thread.sleep(100);
}
catch (InterruptedException e1) {
e1.printStackTrace();
}
ShoppingList list = new ShoppingList(this.getFilesDir() + inputtext);
while(stop == 0) {
AlertDialog.Builder builder2 = new AlertDialog.Builder(this);
builder.setTitle("Enter an item:");
final EditText input2 = new EditText(this);
input2.setInputType(InputType.TYPE_CLASS_TEXT);
builder.setView(input2);
builder.setPositiveButton("Add", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
inputtext = input.getText().toString();
}
});
builder.setNegativeButton("Stop", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
stop = 1;
}
});
builder2.show();
try {
list.addItem(inputtext);
}
catch (IOException e) {
e.printStackTrace();
}
}