我收到来自用户的错误消息:
java.lang.NullPointerException
at com.jcolom.olakease.MainActivity$1.onClick(MainActivity.java:54)
at android.view.View.performClick(View.java:2408)
at android.view.View$PerformClick.run(View.java:8816)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4633)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at dalvik.system.NativeStart.main(Native Method)
我的 MainActivity 是这样的:
package com.jcolom.olakease;
import android.os.Bundle;
import android.app.Activity;
import java.io.InputStream;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import com.colom.ola.ke.ase.R;
public class MainActivity extends Activity {
public Button olakease_button1;
public Button olakease_button2;
public Button olakease_button3;
public Button olakease_button4;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
olakease_button1 = (Button)findViewById(R.id.olakease_button1);
olakease_button2 = (Button)findViewById(R.id.olakease_button2);
olakease_button3 = (Button)findViewById(R.id.olakease_button3);
olakease_button4 = (Button)findViewById(R.id.olakease_button4);
InputStream fraw = null;
fraw = getResources().openRawResource(R.raw.olakease1);
fraw = getResources().openRawResource(R.raw.olakease2);
fraw = getResources().openRawResource(R.raw.olakease3);
olakease_button1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
MediaPlayer mp = MediaPlayer.create(getBaseContext(),
R.raw.olakease1);
mp.start();
}
});
olakease_button2.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
MediaPlayer mp = MediaPlayer.create(getBaseContext(),
R.raw.olakease2);
mp.start();
}
});
olakease_button3.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
MediaPlayer mp = MediaPlayer.create(getBaseContext(),
R.raw.olakease3);
mp.start();
}
});
olakease_button4.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
MediaPlayer mp = MediaPlayer.create(getBaseContext(),
R.raw.olakease4);
mp.start();
}
});
}
}
我的 AndroidManifest 是:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.colom.ola.ke.ase"
android:versionCode="2"
android:versionName="1.1" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<application
android:allowBackup="true"
android:icon="@drawable/icono"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:screenOrientation="portrait"
android:name="MainActivity">
<activity
android:name="com.jcolom.olakease.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>
</application>
</manifest>
我该怎么办??正常吗?请,如果您想在您的移动设备上试用我的应用程序.. 这是 Play 商店链接:https ://play.google.com/store/apps/details?id=com.colom.ola.ke.ase&feature =more_from_developer#?t=W251bGwsMSwyLDEwMiwiY29tLmNvbG9tLm9sYS5rZS5hc2UiXQ ..