开发者

Issue on setOnclickListener

开发者 https://www.devze.com 2023-01-12 09:16 出处:网络
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 x开发者_

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 x开发者_如何学Goml file under the layout folder.

How do I do this?


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));

0

精彩评论

暂无评论...
验证码 换一张
取 消