Saturday, June 25, 2011

Getting start with String in Android

//save as string:
private EditText username;
String usrTxt;
usrTxt = username.getText().toString();

//show message!
private TextView status;
status.setText("Login" + usrTxt + " : " + pwdTxt);

//from String to Integer
              final String glassNum=num.getText().toString();
              int  glassInt =  Integer.parseInt(glassNum);
 test.setText("hello "+ glassInt)


//from double to Integer

double myDouble = 420.5;
 
        //Type cast double to int
        int i = (int)myDouble;
 

Android code example Copyright © 2011 -- Template created by O Pregador -- Powered by Blogger