0
我想創建一個帶有字符串密碼的應用程序,它所做的一切都是遍歷所有可能的字符和數字組合,直到找到正確的字符串,如下所示:在android項目中爲EditText創建「密碼檢測器」
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class PasswordDetector extends AppCompatActivity {
private static final String PASSWORD = "abc123";
private Button search;
private EditText combination;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
search.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//here I want the loop to run, untill it hits the PASSWORD
combination.setText("combinations");
if (combination.getText().toString().equals(PASSWORD)) {
Toast.makeText(PasswordDetector.this, "Success", Toast.LENGTH_SHORT).show();
}
}
});
}
}
我該如何處理它?