tags:

views:

27

answers:

1

I have two buttons set, "OK" and "Cancel" in main.xml. I have setOnclickListener for the Cancel. When I click on OK i need another xml file say abc.xml to get displayed. I have added that xml file under the layout folder.

How do I do this?

A: 

I guess your abc.xml is another Activity. What you need to do is:

  • Create a class that extends Activity, for example Abc.
  • In the onCreate() method call setContentView(R.layout.abc.xml).
  • Add the Activity to the AndroidManifest file.
  • In the OnClickListener of the button, write:

    startActivity(new Intent(YouActivityWithTheButtons.this, Abc.class));

Macarse
Thanks Macarse!!
Sana