2014-06-30 2 views
0

force App ferme lorsque je tente de démarrer cette intention et afficher le texte que je l'ai déjà inclus le setContentView(R.layout.activity_try_text);Forces d'application à se fermer lorsque je commence une autre activité par intention et d'afficher un texte

public class TryText extends ActionBarActivity { 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_try_text); 
     TextView text = (TextView)findViewById(R.id.textView11); 
     text.setText("hi"); 

    } 
} 

Et voici le logcat

06-30 12: 03: 05.115: I/Processus (698): Signal d'envoi. PID: 698 SIG: 9 06-30 12: 03: 11.802: D/AndroidRuntime (1327): Arrêt VM 06-30 12: 03: 11.802: W/dalvikvm (1327): threadid = 1: thread sortant avec exception non interceptée (groupe = 0x41b7bd40) 06-30 12: 03: 11.807: E/AndroidRuntime (1327): FATAL EXCEPTION: principal 06-30 12: 03: 11.807: E/AndroidRuntime (1327): Processus: com.example .bag, PID: 1327 06-30 12: 03: 11.807: E/AndroidRuntime (1327): java.lang.RuntimeException: Impossible de démarrer l'activité ComponentInfo {com.example.bag/com.example.bag.TryText}: java.lang.NullPointerException 06-30 12: 03: 11.807: E/AndroidRuntime (1327): à l'adresse android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2209) 06-30 12: 03: 11.807: E/AndroidRuntime (1327): at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2269) 06-30 12: 03: 11.807: E/AndroidRuntime (1327): à l'adresse android.app.ActivityThread.access $ 800 (ActivityThread.java:139) 06-30 12: 03: 11.807: E/AndroidRuntime (1327): à l'adresse android.app.ActivityThread $ H.handleMessage (ActivityThread.java:1210) 06-30 12: 03: 11.807: E/AndroidRuntime (1327): à l'adresse android.os.Handler.dispatchMessage (Handler.java:102) 06-30 12: 03: 11.807: E/AndroidRuntime (1327): à android.os.Looper.loop (Looper.java:136) 06-30 12: 03: 11.807: E/AndroidRuntime (1327): à android .app.ActivityThread.main (ActivityThread.java:5102) 06-30 12: 03: 11.807: E/AndroidRuntime (1327): à java.lang.reflect.Method.invokeNative (méthode native) 06-30 12: 03: 11.807: E/AndroidRuntime (1327): à java.lang.reflect.Method.invoke (Method.java:515) 06-30 12: 03: 11.807: E/AndroidRuntime (13 27): à l'adresse com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:785) 06-30 12: 03: 11.807: E/AndroidRuntime (1327): at com.android.internal.os. ZygoteInit.main (ZygoteInit.java:601) 06-30 12: 03: 11.807: E/AndroidRuntime (1327): à dalvik.system.NativeStart.main (méthode native) 06-30 12: 03: 11.807: E/AndroidRuntime (1327): Causé par: java.lang.NullPointerException 06-30 12: 03: 11.807: E/AndroidRuntime (1327): à android.view.ViewGroup.addViewInner (ViewGroup.java:3561) 06-30 12: 03: 11.807: E/AndroidRuntime (1327): à android.view.ViewGroup.addView (ViewGroup.java:3415) 06-30 12: 03: 11.807: E/AndroidRuntime (1327): à android.view. ViewGroup.addView (ViewGroup.java:3391) 06-30 12: 03: 11.807: E/AndroidRuntime (1327): sur com.android.internal.policy.impl.PhoneWindow. setContentView (PhoneWindow.java:309) 06-30 12: 03: 11.807: E/AndroidRuntime (1327): à l'adresse com.android.internal.policy.impl.PhoneWindow.setContentView (PhoneWindow.java:299) 06-30 12: 03: 11.807: E/AndroidRuntime (1327): at android.app.Activity.setContentView (Activity.java:1957) 06-30 12: 03: 11.807: E/AndroidRuntime (1327): sur android.support. v7.app.ActionBarActivity.superSetContentView (ActionBarActivity.java:220) 06-30 12: 03: 11.807: E/AndroidRuntime (1327): à l'adresse android.support.v7.app.ActionBarActivityDelegateICS.setContentView (ActionBarActivityDelegateICS.java:106) 06-30 12: 03: 11.807: E/AndroidRuntime (1327): à l'adresse android.support.v7.app.ActionBarActivity.setContentView (ActionBarActivity.java:81) 06-30 12: 03: 11.807: E/AndroidRuntime (1327): à com.example.bag.TryText.onCreate (TryText.java:21) 06-30 12: 03: 11.807: E/AndroidRuntime (1327): at android.app.Activity.performCreate (Activity.java:5248) 06-30 12: 03: 11.807: E/AndroidRuntime (1327): à android.app.Instrumentation.callActivityOnCreate (Instrumentation.java: 1110) 06-30 12: 03: 11.807: E/AndroidRuntime (1327): à l'adresse android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2173) 06-30 12: 03: 11.807: E/AndroidRuntime (1327): ... 11 plus

+0

S'il vous plaît poster logcat – Aniruddha

Répondre

0

Essayez de supprimer cette ligne:

setContentView(text); 

Comme vous l'avez déjà gonflé votre vue.

Si cela ne fonctionne pas, publiez votre logcat.

Espérons que ça aide

Questions connexes