Button b1=(Button)findViewById(R.id.b1);
final EditText ed=(EditText)findViewById(R.id.ed1);
TextView t=(TextView)findViewById(R.id.t1);
b1.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
abc=ed.getText().toString();
Intent intent=new Intent(v.getContext(),AnotherActivity.class);
startActivityForResult(intent,0);
}
})
これは私のmainactivityコードです。ボタンのクリックで別のアクティビティを開始していますが、代わりにエラーが発生し、アプリがクラッシュして、誰かがこのエラーを削除するのを手伝ってくれます/
02-23 14:20:06.557: E/AndroidRuntime(2732): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.newpicker/com.example.newpicker.AnotherActivity}: java.lang.NullPointerException
これは私のlogcatです
public class AnotherActivity extends Activity {
static Context context;
public boolean a;
private DownloadManager downloadManager;
static TextView tt1;
String url="http://www.digitalmarketingbox.com/";
private DownloadManager dm;
String v1,v2;
ArrayList<String> imageid = new ArrayList<String>();
ArrayList<String> imagepath = new ArrayList<String>();
ArrayList<String> playlist_content = new ArrayList<String>();
ArrayList<String> al=new ArrayList();
String i1;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.showimages);
//tt1=(TextView)findViewById(R.id.text1);
TextView tt1=(TextView)findViewById(R.id.it);
AnotherActivity.tt1.append(MainActivity.abc);
}
02-23 14:35:08.561: D/dalvikvm(4900): Late-enabling CheckJNI
02-23 14:35:08.702: D/libEGL(4900): loaded /system/lib/egl/libEGL_adreno200.so
02-23 14:35:08.702: D/libEGL(4900): loaded /system/lib/egl/libGLESv1_CM_adreno200.so
02-23 14:35:08.702: D/libEGL(4900): loaded /system/lib/egl/libGLESv2_adreno200.so
02-23 14:35:08.702: I/Adreno200-EGL(4900): <eglInitialize:269>: EGL 1.4 QUALCOMM build: Nondeterministic AU_full_mako_PARTNER-ANDROID/JB-MR1-DEV_CL2961380_release_AU (CL2961380)
02-23 14:35:08.702: I/Adreno200-EGL(4900): Build Date: 12/10/12 Mon
02-23 14:35:08.702: I/Adreno200-EGL(4900): Local Branch:
02-23 14:35:08.702: I/Adreno200-EGL(4900): Remote Branch: m/partner-android/jb-mr1-dev
02-23 14:35:08.702: I/Adreno200-EGL(4900): Local Patches: NONE
02-23 14:35:08.702: I/Adreno200-EGL(4900): Reconstruct Branch: NOTHING
02-23 14:35:08.742: D/OpenGLRenderer(4900): Enabling debug mode 0
02-23 14:35:12.936: D/AndroidRuntime(4900): Shutting down VM
02-23 14:35:12.936: W/dalvikvm(4900): threadid=1: thread exiting with uncaught exception (group=0x41d10930)
02-23 14:35:12.946: E/AndroidRuntime(4900): FATAL EXCEPTION: main
02-23 14:35:12.946: E/AndroidRuntime(4900): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.newpicker/com.example.newpicker.AnotherActivity}: java.lang.NullPointerException
02-23 14:35:12.946: E/AndroidRuntime(4900): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
02-23 14:35:12.946: E/AndroidRuntime(4900): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
02-23 14:35:12.946: E/AndroidRuntime(4900): at android.app.ActivityThread.access$600(ActivityThread.java:141)
02-23 14:35:12.946: E/AndroidRuntime(4900): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
02-23 14:35:12.946: E/AndroidRuntime(4900): at android.os.Handler.dispatchMessage(Handler.java:99)
02-23 14:35:12.946: E/AndroidRuntime(4900): at android.os.Looper.loop(Looper.java:137)
02-23 14:35:12.946: E/AndroidRuntime(4900): at android.app.ActivityThread.main(ActivityThread.java:5041)
02-23 14:35:12.946: E/AndroidRuntime(4900): at java.lang.reflect.Method.invokeNative(Native Method)
02-23 14:35:12.946: E/AndroidRuntime(4900): at java.lang.reflect.Method.invoke(Method.java:511)
02-23 14:35:12.946: E/AndroidRuntime(4900): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-23 14:35:12.946: E/AndroidRuntime(4900): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-23 14:35:12.946: E/AndroidRuntime(4900): at dalvik.system.NativeStart.main(Native Method)
02-23 14:35:12.946: E/AndroidRuntime(4900): Caused by: java.lang.NullPointerException
02-23 14:35:12.946: E/AndroidRuntime(4900): at com.example.newpicker.AnotherActivity.onCreate(AnotherActivity.java:41)
02-23 14:35:12.946: E/AndroidRuntime(4900): at android.app.Activity.performCreate(Activity.java:5104)
02-23 14:35:12.946: E/AndroidRuntime(4900): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
02-23 14:35:12.946: E/AndroidRuntime(4900): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
02-23 14:35:12.946: E/AndroidRuntime(4900): ... 11 more
これは私の完全なログキャットです