我有一个让我发疯的问题,我想从包中获取“n”字符串值,当我单击“发送按钮”时,avd 会以某种方式崩溃。
活动一
public void enviar(View view){
Intent intento=new Intent(this, Segunda.class);
Bundle bundle=new Bundle();
String usuarioS=editText.getText().toString();
editText1 = (EditText) findViewById(R.id.usuarioID);
bundle.putString("usuario", usuarioS);
intento.putExtras(bundle);
startActivity(intento);
}
活动二
public class Segunda extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_segunda);
String message,message1;
Bundle extras = getIntent().getExtras();
message1 = extras.getString("usuario");
TextView textView1 = (TextView)findViewById(R.id.usuariofID);
textView1.setText(message1);
}
那是我的代码。我在哪里搞砸了?
LOGCAT(更新)
01-22 19:54:54.055: W/Trace(1270): Unexpected value from nativeGetEnabledTags: 0
01-22 19:54:54.104: D/AndroidRuntime(1270): Shutting down VM
01-22 19:54:54.104: W/dalvikvm(1270): threadid=1: thread exiting with uncaught exception (group=0x40a70930)
01-22 19:54:54.155: E/AndroidRuntime(1270): FATAL EXCEPTION: main
01-22 19:54:54.155: E/AndroidRuntime(1270): java.lang.IllegalStateException: Could not execute method of the activity
01-22 19:54:54.155: E/AndroidRuntime(1270): at android.view.View$1.onClick(View.java:3597)
01-22 19:54:54.155: E/AndroidRuntime(1270): at android.view.View.performClick(View.java:4202)
01-22 19:54:54.155: E/AndroidRuntime(1270): at android.view.View$PerformClick.run(View.java:17340)
01-22 19:54:54.155: E/AndroidRuntime(1270): at android.os.Handler.handleCallback(Handler.java:725)
01-22 19:54:54.155: E/AndroidRuntime(1270): at android.os.Handler.dispatchMessage(Handler.java:92)
01-22 19:54:54.155: E/AndroidRuntime(1270): at android.os.Looper.loop(Looper.java:137)
01-22 19:54:54.155: E/AndroidRuntime(1270): at android.app.ActivityThread.main(ActivityThread.java:5039)
01-22 19:54:54.155: E/AndroidRuntime(1270): at java.lang.reflect.Method.invokeNative(Native Method)
01-22 19:54:54.155: E/AndroidRuntime(1270): at java.lang.reflect.Method.invoke(Method.java:511)
01-22 19:54:54.155: E/AndroidRuntime(1270): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-22 19:54:54.155: E/AndroidRuntime(1270): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-22 19:54:54.155: E/AndroidRuntime(1270): at dalvik.system.NativeStart.main(Native Method)
01-22 19:54:54.155: E/AndroidRuntime(1270): Caused by: java.lang.reflect.InvocationTargetException
01-22 19:54:54.155: E/AndroidRuntime(1270): at java.lang.reflect.Method.invokeNative(Native Method)
01-22 19:54:54.155: E/AndroidRuntime(1270): at java.lang.reflect.Method.invoke(Method.java:511)
01-22 19:54:54.155: E/AndroidRuntime(1270): at android.view.View$1.onClick(View.java:3592)
01-22 19:54:54.155: E/AndroidRuntime(1270): ... 11 more
01-22 19:54:54.155: E/AndroidRuntime(1270): Caused by: java.lang.NullPointerException
01-22 19:54:54.155: E/AndroidRuntime(1270):atcom.example.actividadesss.MainActivity.enviar(MainActivity.java:301-22 19:54:54.155: E/AndroidRuntime(1270): ... 14 more
01-22 19:54:54.224:W/ActivityManager(286):Forcefinishingactivitycom.example.actividadesss/.MainActivity