When we click on button, we should go to another activity. Lets use existing project.
add second activity on button listenerL
add second activity on button listenerL
clickButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { //Toast.makeText(getApplicationContext(),"You just clicked button",Toast.LENGTH_LONG).show(); Intent intent = new Intent(MainActivity.this,SecondActivity.class); startActivity(intent); } });
Now add second activity:
right click on res folder and create SecondActivity:
New--> Activity--> Empty Activity
When we run code as shown below,
When we click on 'CLICK ME' button, below second activity comes:
No comments:
Post a Comment