• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Storing input as variable.

Booocubs

Newbie
I simply want to take an input from a number type edittext, once the button is pressed, and turn that input into a variable, say X. How do I do this?
 
Put this inside your onClick event for the button
Code:
EditText txt = (EditText)findViewById(R.id.txt);
String number = txt.getString().toString();
 
Simply giving you code isn't helpful to you. You need to understand why the code does what it does so that you know when and where to use it in the future.
 
Back
Top Bottom