I have the following code, which should change the value of an EditText field when the button is clicked…
public class ConvertActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final Button b1 = (Button) findViewById(R.id.b1);
b1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
b1.setEnabled(true);
EditText editText2 = (EditText)findViewById(R.id.editText2);
String editTextStr2 = editText2.getText().toString();
editText2.setText("empty");
}
});
}
}
However, when I click the button, the text doesn’t change. Is there something wrong with my code?
comment out the line
and see if it set editText2 to “empty” – my guess is m.getND() is returning null