After trying a lot i decided to ask question on stackoverflow, I create a class for using on button click and start an intent from this class.
import android.app.Activity;
import android.content.Intent;
import android.view.View;
public class OnClickListener implements android.view.View.OnClickListener{
Activity current;
Object goTo;
public OnClickListener(Activity arg0, Activity arg1){
this.current = arg0;
this.goTo = arg1;
}
@Override
public void onClick(View v) {
Intent intent = new Intent(current, goTo.getClass());
current.startActivity(intent);
}
}
and passing parameter like this:
Button button = (Button)findViewById(R.id.class2_btn);
Class2 class2 = new Class2();
OnClickListener listener = new OnClickListener(class1.this, class2);
button.setOnClickListener(listener);
why this is not working? after clicking button why this is not going to next class?
Please help me.
There are some points i want to figure out here :
Intent intent = new Intent(current_activity.this, target_activty.class);
current.startActivity(intent);