jeudi 21 mai 2015

Android unable to retrieve EditText value and length

guys i have a simple problem about android Edittext value and length retrive, i used a fileselectorActivity to selected a file path and intent back(bring extra file path) to mainActivity,the mainactivity require multiple file path which means i have to intent jump multiple times. each jump intent will set value to different edittext

i used Edittext.getText().toString().isEmpty() privatekeypathedit.getText().length() etc but still unable to get the value and length

Does someone can help this? thank you so much

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.decryption_activity);
    privatekeypathedit = (EditText) findViewById(R.id.privatekeypathEdittext);
    targetfilepathedit = (EditText) findViewById(R.id.targetfilepathEdit);
    privatekeypath();
    targetfilepath();
    startdecryption();
    a = privatekeypathedit.getText().toString();
    b = targetfilepathedit.getText().toString();
    Intent intent = getIntent();
    String filepath = intent.getStringExtra("filepath");

    Toast.makeText(this, a, Toast.LENGTH_LONG).show();  here is null
    Toast.makeText(this, b, Toast.LENGTH_LONG).show();  here is null
    if (privatekeypathedit.getText().toString().isEmpty()) {

        privatekeypathedit.setText(filepath);

    } else if (targetfilepathedit.getText().toString().isEmpty()) {

        targetfilepathedit.setText(filepath);

    }

}

This part is bring file path intent back to mainactivity private void onFileClick(Option o) {

    Toast.makeText(this, "You selected "+o.getName(), Toast.LENGTH_SHORT).show();
    Intent intent = new Intent(selectddecrypfile.this,decryptActivity.class);
    intent.putExtra("filepath", o.getPath());
    startActivity(intent);

}

Aucun commentaire:

Enregistrer un commentaire