forum

Home / DeveloperSection / Forums / How to set textview from another activity using intent extra?

How to set textview from another activity using intent extra?

Anonymous User335114-Oct-2014

I am trying to get a text view to update after a user has typed in a string from another result. When using this method below I get what appears to be the edit text's code address. Something like "android.widget.Edittext(b142f388 etc." regardless of what the user types in on the other activity. What am I missing here?

String collected from user:

private void enterClicked() {
    Log.i(TAG,"Entered enterClicked()");
    //Save user provided input from the EditText field
    String result = mEditText.toString();
    //Create a new intent and save the input from the EditText field as an extra
    Intent i = new Intent(ExplicitlyLoadedActivity.this, ActivityLoaderActivity.class);
    i.putExtra("RESULT_STRING", result);
    //Set Activity's result with result code RESULT_OK
    setResult(RESULT_OK, i);
    //Finish the Activity
    finish();
}

Activity Result:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.i(TAG, "Entered onActivityResult()");
    // RESULT_OK result code and a recognized request code
    // If so, update the Textview showing the user-entered text.
    if ( resultCode == RESULT_OK){
        if(requestCode == GET_TEXT_REQUEST_CODE){           
        String userData = data.getStringExtra("RESULT_STRING");
        mUserTextView.setText(userData);
    }    
}
}


Updated on 14-Oct-2014
I am a content writter !

Can you answer this question?


Answer

2 Answers

Liked By