Android 简单按钮事件不工作?
嗨,我想问一下,为什么我的按钮在点击时不起作用?我只是复制了我的其他版面按钮代码,并尝试自己创建,但仍然不起作用Android 简单按钮事件不工作?,android,button,Android,Button,嗨,我想问一下,为什么我的按钮在点击时不起作用?我只是复制了我的其他版面按钮代码,并尝试自己创建,但仍然不起作用 <ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent"> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:or
<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/categories" >
<Button
android:id="@+id/btnLearner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/btnBeginner"
android:layout_centerHorizontal="true"
android:background="@drawable/learner_menu" />
<Button
android:id="@+id/btnBeginner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/btnLearner"
android:layout_alignParentTop="true"
android:background="@drawable/beginner_menu" />
</RelativeLayout>
</ScrollView>
</LinearLayout>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Splash"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ThesisActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.THESISACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".logipic.Menu"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.MENU" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
<activity
android:name=".Gameplay"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.GAMEPLAY" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
<activity
android:name=".Beginner"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.BEGINNER" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
</application>
</manifest>
这是我的密码
<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/categories" >
<Button
android:id="@+id/btnLearner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/btnBeginner"
android:layout_centerHorizontal="true"
android:background="@drawable/learner_menu" />
<Button
android:id="@+id/btnBeginner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/btnLearner"
android:layout_alignParentTop="true"
android:background="@drawable/beginner_menu" />
</RelativeLayout>
</ScrollView>
</LinearLayout>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Splash"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ThesisActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.THESISACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".logipic.Menu"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.MENU" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
<activity
android:name=".Gameplay"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.GAMEPLAY" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
<activity
android:name=".Beginner"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.BEGINNER" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
</application>
</manifest>
.爪哇
包com.thesis.logipic
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
public class Menu extends Activity
{
Button beginner;
@Override
protected void onCreate(Bundle MenuButtons) {
super.onCreate(MenuButtons);
}
public void onClick(View v)
{
Button clickedButton = (Button) v;
switch (clickedButton.getId())
{
case R.id.btnBeginner:
setContentView(R.layout.gameplay);
break;
case R.id.btnLearner:
setContentView(R.layout.menu);
break;
}
}
}
<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/categories" >
<Button
android:id="@+id/btnLearner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/btnBeginner"
android:layout_centerHorizontal="true"
android:background="@drawable/learner_menu" />
<Button
android:id="@+id/btnBeginner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/btnLearner"
android:layout_alignParentTop="true"
android:background="@drawable/beginner_menu" />
</RelativeLayout>
</ScrollView>
</LinearLayout>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Splash"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ThesisActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.THESISACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".logipic.Menu"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.MENU" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
<activity
android:name=".Gameplay"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.GAMEPLAY" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
<activity
android:name=".Beginner"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.BEGINNER" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
</application>
</manifest>
.xml
<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/categories" >
<Button
android:id="@+id/btnLearner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/btnBeginner"
android:layout_centerHorizontal="true"
android:background="@drawable/learner_menu" />
<Button
android:id="@+id/btnBeginner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/btnLearner"
android:layout_alignParentTop="true"
android:background="@drawable/beginner_menu" />
</RelativeLayout>
</ScrollView>
</LinearLayout>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Splash"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ThesisActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.THESISACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".logipic.Menu"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.MENU" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
<activity
android:name=".Gameplay"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.GAMEPLAY" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
<activity
android:name=".Beginner"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.BEGINNER" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
</application>
</manifest>
舱单呢
<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/categories" >
<Button
android:id="@+id/btnLearner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/btnBeginner"
android:layout_centerHorizontal="true"
android:background="@drawable/learner_menu" />
<Button
android:id="@+id/btnBeginner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/btnLearner"
android:layout_alignParentTop="true"
android:background="@drawable/beginner_menu" />
</RelativeLayout>
</ScrollView>
</LinearLayout>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Splash"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ThesisActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.THESISACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".logipic.Menu"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.MENU" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
<activity
android:name=".Gameplay"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.GAMEPLAY" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
<activity
android:name=".Beginner"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.BEGINNER" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
</application>
</manifest>
试试这个:
<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/categories" >
<Button
android:id="@+id/btnLearner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/btnBeginner"
android:layout_centerHorizontal="true"
android:background="@drawable/learner_menu" />
<Button
android:id="@+id/btnBeginner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/btnLearner"
android:layout_alignParentTop="true"
android:background="@drawable/beginner_menu" />
</RelativeLayout>
</ScrollView>
</LinearLayout>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Splash"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ThesisActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.THESISACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".logipic.Menu"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.MENU" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
<activity
android:name=".Gameplay"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.GAMEPLAY" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
<activity
android:name=".Beginner"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.BEGINNER" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
</application>
</manifest>
@Override
protected void onCreate(Bundle MenuButtons) {
super(MenuButtons);
((Button) findViewById(R.id.btnBeginner)).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
setContentView(R.layout.gameplay);
}
});
((Button) findViewById(R.id.btnLearner)).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
setContentView(R.layout.menu);
}
});
}
您必须修改您的活动:
<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/categories" >
<Button
android:id="@+id/btnLearner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/btnBeginner"
android:layout_centerHorizontal="true"
android:background="@drawable/learner_menu" />
<Button
android:id="@+id/btnBeginner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/btnLearner"
android:layout_alignParentTop="true"
android:background="@drawable/beginner_menu" />
</RelativeLayout>
</ScrollView>
</LinearLayout>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Splash"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ThesisActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.THESISACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".logipic.Menu"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.MENU" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
<activity
android:name=".Gameplay"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.GAMEPLAY" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
<activity
android:name=".Beginner"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.BEGINNER" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
</application>
</manifest>
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class Menu extends Activity implements OnClickListener {
private Button beginner, learner;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); // Your layout
beginner = (Button) findViewById(R.id.btnBeginner);
beginner.setOnClickListener(this);
learner = (Button) findViewById(R.id.btnLearner);
learner.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btnBeginner:
setContentView(R.layout.gameplay);
break;
case R.id.btnLearner:
setContentView(R.layout.menu);
break;
}
}
}
将contentview设置到onCreate方法中
<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/categories" >
<Button
android:id="@+id/btnLearner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/btnBeginner"
android:layout_centerHorizontal="true"
android:background="@drawable/learner_menu" />
<Button
android:id="@+id/btnBeginner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/btnLearner"
android:layout_alignParentTop="true"
android:background="@drawable/beginner_menu" />
</RelativeLayout>
</ScrollView>
</LinearLayout>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Splash"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ThesisActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.THESISACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".logipic.Menu"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.MENU" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
<activity
android:name=".Gameplay"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.GAMEPLAY" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
<activity
android:name=".Beginner"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.BEGINNER" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
</application>
</manifest>
setContentView(R.layout.menu);
然后将以下标记添加到xml按钮元素中
<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/categories" >
<Button
android:id="@+id/btnLearner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/btnBeginner"
android:layout_centerHorizontal="true"
android:background="@drawable/learner_menu" />
<Button
android:id="@+id/btnBeginner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/btnLearner"
android:layout_alignParentTop="true"
android:background="@drawable/beginner_menu" />
</RelativeLayout>
</ScrollView>
</LinearLayout>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Splash"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ThesisActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.THESISACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".logipic.Menu"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.MENU" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
<activity
android:name=".Gameplay"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.GAMEPLAY" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
<activity
android:name=".Beginner"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.BEGINNER" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
</application>
</manifest>
android:onClick="onClick"
编辑
<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/categories" >
<Button
android:id="@+id/btnLearner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/btnBeginner"
android:layout_centerHorizontal="true"
android:background="@drawable/learner_menu" />
<Button
android:id="@+id/btnBeginner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/btnLearner"
android:layout_alignParentTop="true"
android:background="@drawable/beginner_menu" />
</RelativeLayout>
</ScrollView>
</LinearLayout>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Splash"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ThesisActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.THESISACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".logipic.Menu"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.MENU" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
<activity
android:name=".Gameplay"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.GAMEPLAY" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
<activity
android:name=".Beginner"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.BEGINNER" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
</application>
</manifest>
请放心。这是你修改过的代码
<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/categories" >
<Button
android:id="@+id/btnLearner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/btnBeginner"
android:layout_centerHorizontal="true"
android:background="@drawable/learner_menu" />
<Button
android:id="@+id/btnBeginner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/btnLearner"
android:layout_alignParentTop="true"
android:background="@drawable/beginner_menu" />
</RelativeLayout>
</ScrollView>
</LinearLayout>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Splash"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ThesisActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.THESISACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".logipic.Menu"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.MENU" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
<activity
android:name=".Gameplay"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.GAMEPLAY" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
<activity
android:name=".Beginner"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.BEGINNER" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
</application>
</manifest>
@Override
protected void onCreate(Bundle MenuButtons) {
super.onCreate(MenuButtons);
setContentView(R.layout.menu);
}
和xml
<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/categories" >
<Button
android:id="@+id/btnLearner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/btnBeginner"
android:layout_centerHorizontal="true"
android:background="@drawable/learner_menu" />
<Button
android:id="@+id/btnBeginner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/btnLearner"
android:layout_alignParentTop="true"
android:background="@drawable/beginner_menu" />
</RelativeLayout>
</ScrollView>
</LinearLayout>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Splash"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ThesisActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.THESISACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".logipic.Menu"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.MENU" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
<activity
android:name=".Gameplay"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.GAMEPLAY" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
<activity
android:name=".Beginner"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thesis.logipic.BEGINNER" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
</application>
</manifest>
<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/categories" >
<Button
android:id="@+id/btnLearner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/btnBeginner"
android:layout_centerHorizontal="true"
android:background="@drawable/learner_menu"
android:onClick="onClick"
/>
<Button
android:id="@+id/btnBeginner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/btnLearner"
android:layout_alignParentTop="true"
android:background="@drawable/beginner_menu"
android:onClick="onClick"
/>
</RelativeLayout>
</ScrollView>
你到底想做什么?您从未设置内容视图。尝试一些来自互联网的安卓基础教程。当我点击它时,它有一个错误不像以前它什么都不做hahathanks和顺便说一句,我做了代码,但当我点击按钮时,它强制关闭,但比没有响应好hahaIt显示“安卓已停止工作意外强制关闭”但是当我试着把它放在第三个布局中时,会显示它工作得很好