简体   繁体   English

日食开普勒如何添加按钮以连接到另一种形式

[英]eclipse kepler how to add button to connect to another form

I have 2 files: main_activity.xml and vision.xml. 我有2个文件:main_activity.xml和vision.xml。 I made a button in main_activity.xml 我在main_activity.xml中做了一个按钮

How can I open the vision.xml using button? 如何使用按钮打开vision.xml? Can you give me codes for MainActivity.java? 可以给我MainActivity.java的代码吗?

In your MainActivity.java add a public method as follows 在您的MainActivity.java中,添加一个公共方法,如下所示

public void startVision(View view){
    Intent intent = new Intent(this,Vision.class);
    startActivity(intent);
}

then in your main_activity.xml make your Button definition look like as follow 然后在您的main_activity.xml中使您的Button定义如下所示

<Button
    ...
    android:onClick="startVision" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM