First, declare your videoButton variable
private Button videoButton;
Then, in your MainActivity, instantiate your button variable and set up your onclick listener
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
videoButton = (Button) findViewById(R.id.single_ticket_add);
videoButton.setOnClickListener(videoButtonOnClickListener);
...
Then have your goToVideoOnClickListener start an intent to open your VideoActivity
private OnClickListener goToVideoOnClickListener = new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new
Intent(MainActivity.this, VideoActivity.class);
startActivity(intent); }
};
Then in VideoActivity in OnCreate set your content view to be the layout video.xml
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.video);
...
2
solved how to call another activity from an image button [closed]