i have a listview with 3 text. NV1 – NV2 – NV3. My problem is when I touch on NV1 the intent show me the layout of NV1. But with the others nothing happen. It just show me the same NV.
I create a 2 method for passing the info.
private void adapter (PT1Activity a){
this.a = a;
}
private void showGame(int nivel){
Intent intent = new Intent (PT1Activity.this, NV1.class);
intent.putExtra("nivel2", nivel);
startActivity(intent);
}
And a:
private PT1Activity a;
adapter(this);
ltNvs.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int position,
long arg3) {
a.showGame(position);
}
});
What I have to do? Pass the information to the other NV2 Activity with a Bundle?? Or something similar?
Your showgame function should be something like this:
However, this assumes all your classes are in the same package. If you want to launch an activity in a different package, the
Intent(this, yourclass.Class)constructor won’t work. Instead, try something like this:Note: your_other_class_name would be something like
NV1, notNV1.class.