Search code examples
androidandroid-edittextgettext

Android EditText value not showing up, getText returns a value


Everything in my Activity is working fine. I'm able to load all the values fine and show in every EditText except one. The sequence of the actions on onCreate is

 @Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.rule_editor);
    initComponents(); //references all private objects to each object in activity layout 
    populateCategorySpinner(); //populates a category spinner
    loadRule(); //loads the rule from a singleton on the basis of an extra data passed from parent activity
    attachEvents(); //attaches event to each object
    Log.d("", txtIdentifierString.getText().toString());
}

The problem is in one of the EditText. The reference in code is txtIdentifierString. The values that I set (by setText()) on it is not showing up in activity on runtime.

Logcat shows up a value from the Log.d method call in last line of the onCreate method, but its not visible in the EditText txtIdentifierString. The EditText box is visible, I can focus on it and type in a value as well.

Does anyone has any idea about it?


Solution

  • I'm answering my own question.
    I debugged the codes and found out that OnItemSelectedListener on a spinner had to reset the EditText in question. The change is triggered before I Logged the value