在Android中設(shè)置一個(gè)按鈕,點(diǎn)擊按鈕跳轉(zhuǎn)至另一個(gè)頁(yè)面。編寫完成后,運(yùn)行不了,點(diǎn)擊該按鈕,程序自動(dòng)關(guān)閉。求求各位大神幫我看看哪里有問(wèn)題。1.這是main.java.里的相關(guān)代碼
@Override
public void onClick(View arg0) {
Intent intent=new Intent(MainActivity.this,TwoActivity.class);
startActivity(intent);
}2.這是two.Java里的代碼
package com.jikexueyuan.testqrcode;
import android.app.Activity;
import android.os.Bundle;
public class TwoActivity extends Activity {
@Override
protected void onCreate(Bundle saveInstanceState){
super.onCreate(saveInstanceState);
setContentView(R.layout.two);
}
}3.這是main.xml的代碼
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.jikexueyuan.testqrcode.MainActivity"
tools:ignore="MergeRootFrame" >
<Button
android:id="@+id/gen"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="36dp"
android:text="生成二維碼"
/>
</LinearLayout>4.這是two.xml里的代碼
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="名片" />
<Button
android:id="@+id/button2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="短信" /></LinearLayout>
添加回答
舉報(bào)
0/150
提交
取消