The click listeners won't work in this aproach:
public class main extends Activity implements View.OnClickListener{
Button BtnMsj, BtnCont, BtnSts;
public static final String MY_DEFAULTSTRING_ID = "defStrID";
private static final int SECOND_REQUESTCODE = 0x1337;
String remitente;
@Override
protected void onCreate(Bundle savedValues)
{
super.onCreate(savedValues);
setContentView(R.layout.menu);
BtnMsj = (Button) this.findViewById(R.id.BtnMsj);
BtnMsj.setOnClickListener(this);
BtnCont = (Button) this.findViewById(R.id.BtnCont);
BtnCont.setOnClickListener(this);
BtnSts = (Button) this.findViewById(R.id.BtnSts);
BtnSts.setOnClickListener(this);
}
public void onClick(View v) {
// TODO Auto-generated method stub
if(v.getId()==R.id.BtnMsj){
Log.d("menuOnClick1", "ifMsj");
Intent i = new Intent(main.this, mensajes.class);
Bundle b = new Bundle();
b.putString("remitente", remitente);
i.putExtras(b);
startActivity(i);
}
if(v.getId()==R.id.BtnCont){
Log.d("menuOnClick2", "ifCont");
Intent i = new Intent(main.this, contactos.class);
startActivity(i);
}
if(v.getId()==R.id.BtnSts){
Log.d("menuOnClick3", "ifSts");
Intent k = new Intent(main.this, status.class);
startActivity(k);
}
}
}
This other one will make them work, but messes data flow, it makes
some variables inaccesible.
public class main extends Activity {
Button BtnMsj,BtnCont, BtnSts, BtnOk, BtnCancel, BtnLogin;
public static final String MY_DEFAULTSTRING_ID = "defStrID";
private static final int SECOND_REQUESTCODE = 0x1337;
@Override
protected void onCreate(Bundle savedValues)
{
super.onCreate(savedValues);
setContentView(R.layout.menu);
BtnMsj = (Button) this.findViewById(R.id.BtnMsj);
BtnMsj.setOnClickListener(new OnClickListener(){
public void onClick(View arg0) {
Intent i = new Intent(main.this, mensajes.class);
Bundle b = new Bundle();
i.putExtras(b);
startActivity(i);
}
});
BtnCont = (Button) this.findViewById(R.id.BtnCont);
BtnCont.setOnClickListener(new OnClickListener(){
public void onClick(View arg0) {
Intent j = new Intent(main.this, ViewContactos.class);
startActivity(j);
}
});
BtnSts = (Button) this.findViewById(R.id.BtnSts);
BtnSts.setOnClickListener(new OnClickListener(){
public void onClick(View arg0) {
Intent j = new Intent(main.this, status.class);
startActivity(j);
}
});
}
}
}
what should I use to make both work?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---