Quantcast
Channel: xda-developers - Android Software and Hacking General [Developers Only]
Viewing all articles
Browse latest Browse all 3614

[Q] [Help] Android App Development

$
0
0
I'm creating the app that will get a number typed by user in EditText. I've set the getinputtype to "number" in XML.

Basically, I want to return the integer in EditText and set firstnum=that no. How can I do that? I've tried following code but it didnt work


int firstno;
TextView result;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.calc);

initializevars();

add.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
// TODO Auto-generated method stub

firstno = Integer.parseInt(etfirstno.getText().toString());

result.setText("The number is " + firstno);
}
});

Viewing all articles
Browse latest Browse all 3614

Trending Articles