I dont know why I cant generate a custom password.
public void GeneratePass(View view) {
EditText TextField = (EditText)findViewById(R.id.DigitsField);
int DigitsNum = Integer.parseInt(TextField.getText().toString());
if (DigitsNum != 1){
Random Pass = new Random();
int num1 = Pass.nextInt(10);
TextView PassText = (TextView) findViewById(R.id.PassText);
PassText.setText(num1);
}
}
I created this Text Field(EditText) In which you can write how many digits you want the password to be, I tried putting
EditText TextField = (EditText)findViewById(R.id.DigitsField);
String Digits = TextField.getText().toString();
int DigitsNum = Integer.parseInt(Num);
and changing the if(DigitsNum == 1)... But when I write the digits(I just code for 1) I tried writing 1 but it just crash or stop working.
Try something like this and modify it to your needs:
Java Code (Add this in your onCreate method):
XML Layout (Edit it with your current layout):