I have a EditText , a textView and a button,
I need to set my textView with the value of my EditText when a button is touched,
but I have a variable not being recognized [sorry noob on android here]
public class XynthaCalcTestActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//buttons
benefixPaButtonPressed();
benefixAdultButtonPressed();
xynthaButtonPressed();
calculateButtonPressed();
//textField == EditText
final EditText et;
et = (EditText)findViewById(R.id.editText1);
}
public void calculateButtonPressed() {
// TODO Auto-generated method stub
Button button = (Button) findViewById(R.id.result);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Log.d("myTag", "result biatch");
String text=et.getText().toString();
Toast msg = Toast.makeText(getBaseContext(),text, Toast.LENGTH_LONG);
msg.show();
}
});
}
}
so on the line with String text=et.getText().toString();
I have the error et cannot be resolved
So …
how to declare my et Edit text so the button Class can see it?
thanks a lot!
Make et a field instead, having the final modifier makes no sense to me there.