Passing Data (Android)


Hantar :


Button btn = (Button) findViewById(R.id.bLogin);
btn.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//EditText usr = (EditText) findViewById(R.id.txtUsr);
// String username = usr.getText().toString();
// int pNama = Integer.parseInt(username);


//Intent Hantar= new Intent(Login.this, Papar.class);
//Hantar.putExtra("satu", pNama);
//startActivity(Hantar);

EditText usr = (EditText) findViewById(R.id.txtUsr);
      Intent i = new Intent(Login.this, Papar.class);
      i.putExtra("SS", usr.getText().toString());    
      startActivity(i);





Terima :

Intent in = getIntent();
String tv1= in.getExtras().getString("SS");
TextView puser = (TextView) findViewById(R.id.zUsr);
puser.setText(tv1);

0 comments:

Catat Ulasan