Android 无法启动活动组件信息
我的程序不起作用了, 我对Android 无法启动活动组件信息,android,nullpointerexception,android-logcat,Android,Nullpointerexception,Android Logcat,我的程序不起作用了, 我对surfaceviewexample类有一些问题。 无法启动activityjava.lang.NullPointerException。 我试着按下tut5按钮,这是我用来启动surfaceview的。 原因是什么? 我做错了什么 SurfaceViewExample.java menu.java 显示 将你的SurfaceViewExample活动声明为那样的活动 <activity android:name="com.example.
surfaceviewexample类有一些问题。
无法启动activityjava.lang.NullPointerException。
我试着按下tut5按钮,这是我用来启动surfaceview的。
原因是什么?
我做错了什么
SurfaceViewExample.java
menu.java
显示
将你的SurfaceViewExample
活动声明为那样的活动
<activity
android:name="com.example.youtubeproject.SurfaceViewExample" >
</activity>
把你的日志贴在这里我想把它写进我的邮箱。但它仍然不起作用。请张贴日志
public class menu extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView (com.example.youtubeproject.R.layout.activity_main);
final MediaPlayer buttonSound = MediaPlayer.create(menu.this,
com.example.youtubeproject.R.raw.button_click);
Button tut1= (Button)findViewById(com.example.youtubeproject.R.id.tutorial1);
Button tut2= (Button)findViewById(com.example.youtubeproject.R.id.tutorial2);
Button tut3= (Button)findViewById(com.example.youtubeproject.R.id.tutorial3);
Button tut4=(Button)findViewById(com.example.youtubeproject.R.id.tutorial4);
Button tut5=(Button)findViewById(com.example.youtubeproject.R.id.tutorial5);
tut1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
buttonSound.start();
setContentView (com.example.youtubeproject.R.layout.tutorial1);
Intent TutorialIntent=new Intent("com.example.youtubeproject.TUTORIAL1");
startActivity(TutorialIntent);
//startActivity(new Intent("com.example.youtubeproject.TUTORIAL1"));
}
});
tut2.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
buttonSound.start();
startActivity(new Intent("com.example.youtubeproject.TUTORIALTWO"));
}
});
tut3.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
buttonSound.start();
setContentView (com.example.youtubeproject.R.layout.wallpapaer);
Intent TutorialIntent=new
Intent("com.example.youtubeproject.TUTORIALTHREE");
startActivity(TutorialIntent);
}
});
tut4.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
buttonSound.start();
Intent TutorialIntent=new
Intent("com.example.youtubeproject.TUTORIALFOUR");
startActivity(TutorialIntent);
//setContentView (com.example.youtubeproject.R.layout.wallpapaer);
//Intent TutorialIntent=new
Intent("com.example.youtubeproject.TUTORIALTHREE");
//startActivity(TutorialIntent);
}
});
tut5.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
buttonSound.start();
//startActivity(new Intent("com.example.youtubeproject.TUTORIALFIVE"));
Intent TutorialIntent=new
Intent("com.example.youtubeproject.TUTORIALFIVE");
startActivity(TutorialIntent);
//setContentView (com.example.youtubeproject.R.layout.wallpapaer);
//Intent TutorialIntent=new
Intent("com.example.youtubeproject.TUTORIALTHREE");
//startActivity(TutorialIntent);
}
});
}
public boolean onCreateOptionsMenu(Menu menu)
{
super.onCreateOptionsMenu(menu);
MenuInflater awesome=getMenuInflater();
awesome.inflate(com.example.youtubeproject.R.menu.main_menu,menu);
return true;
}
public boolean onOptionsItemSelected(MenuItem item){
switch(item .getItemId()){
case com.example.youtubeproject.R.id.menuSweet:
startActivity(new Intent("com.example.youtubeproject.SWEET"));
return true;
case com.example.youtubeproject.R.id.menuToast:
Toast andEggs=Toast.makeText(menu.this,"this is a toast
",Toast.LENGTH_LONG);
andEggs.show();
return true;
}
return false;
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.youtubeproject"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.SET_WALLPAPER"></uses-permission>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
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=".menu"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.example.youtubeproject.MENU" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Tutorial1"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.example.youtubeproject.TUTORIAL1" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".TutoralTwo"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.example.youtubeproject.TUTORIALTWO" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".TutorialThree"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.example.youtubeproject.TUTORIALTHREE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".SurfaceViewExample"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.example.youtubeproject.TUTORIALFIVE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".TutorialFour"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.example.youtubeproject.TUTORIALFOUR" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Sweet"
android:label="@string/app_name"
android:theme="@android:style/Theme.Dialog" >
<intent-filter>
<action android:name="com.example.youtubeproject.SWEET" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
<activity
android:name="com.example.youtubeproject.SurfaceViewExample" >
</activity>