Hi, I am trying to provide a default input value for an EditText input field.
Simplified code segment is as follows:-
package xxx.xxx.xxx;
.
.
public class UserInput extends Activity {
private EditText fieldInput;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.userinput);
findView();
dataInput();
setListeners(); // code of setListeners() not included here for simplicity
}
private void findViews() {
fieldInput = (EditText)findViewById (R.id.field_input);
}
private void dataInput(){
//
myInput = "1234";
fieldInput.setText(myInput, TextView.BufferType.EDITABLE);
myInput = fieldInput.getText().toString();
}
The "1234" was displayed on the fieldInput View, after back space and type
different text on the input field and hit the button, the System.out.println
of myInput is still "1234".
I notice that while using Preference, it also use the similar .setText method,
but why the above code doesn't work?
Any help would be highly appreciated.



