null pointer exception lors du démarrage d'une nouvelle activité

D'accord, je suis une exception de pointeur null lorsque je démarre mon activité. Voici le LogCat message:

12-28 04:38:00.350: ERREUR/AndroidRuntime(776): java.lang.RuntimeException: Impossible de démarrer l'activité ComponentInfo{com.acithium.principal/com.acithium.rss.ShowDescription}: java.lang.NullPointerException 
12-28 04:38:00.350: ERREUR/AndroidRuntime(776): au android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401) 
12-28 04:38:00.350: ERREUR/AndroidRuntime(776): au android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417) 
12-28 04:38:00.350: ERREUR/AndroidRuntime(776): au android.app.ActivityThread.accéder à$2100(ActivityThread.java:116) 
12-28 04:38:00.350: ERREUR/AndroidRuntime(776): au android.app.ActivityThread$H. handleMessage(ActivityThread.java:1794) 
12-28 04:38:00.350: ERREUR/AndroidRuntime(776): au android.os.Gestionnaire d'.dispatchMessage(Handler.java:99) 
12-28 04:38:00.350: ERREUR/AndroidRuntime(776): au android.os.Looper.boucle(Looper.java:123) 
12-28 04:38:00.350: ERREUR/AndroidRuntime(776): au android.app.ActivityThread.principale(ActivityThread.java:4203) 
12-28 04:38:00.350: ERREUR/AndroidRuntime(776): à java.lang.de réfléchir.La méthode.invokeNative(Native method) 
12-28 04:38:00.350: ERREUR/AndroidRuntime(776): à java.lang.de réfléchir.La méthode.invoke(la Méthode.java:521) 
12-28 04:38:00.350: ERREUR/AndroidRuntime(776): au com.android.interne.os.ZygoteInit$MethodAndArgsCaller.exécuter(ZygoteInit.java:791) 
12-28 04:38:00.350: ERREUR/AndroidRuntime(776): au com.android.interne.os.ZygoteInit.principale(ZygoteInit.java:549) 
12-28 04:38:00.350: ERREUR/AndroidRuntime(776): à dalvik.système.NativeStart.principale(Native method) 
12-28 04:38:00.350: ERREUR/AndroidRuntime(776): Causée par: java.lang.NullPointerException 
12-28 04:38:00.350: ERREUR/AndroidRuntime(776): au com.acithium.rss.ShowDescription.onCreate(ShowDescription.java:48) 
12-28 04:38:00.350: ERREUR/AndroidRuntime(776): au android.app.L'Instrumentation.callActivityOnCreate(Instrumentation.java:1123) 
12-28 04:38:00.350: ERREUR/AndroidRuntime(776): au android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364) 
12-28 04:38:00.350: ERREUR/AndroidRuntime(776): 11 ... plus 

Ici est la section de code où j'appelle de l'activité:

public void onItemClick(AdapterView parent, View v, int position, long id)
 {
     Log.i(tag,"item clicked! [" + feed.getItem(position).getTitle() + "]");

     Intent itemintent = new Intent(this,com.acithium.rss.ShowDescription.class);
     //Intent itemintent = new Intent();
     //itemintent.setClassName("com.acithium.main", "com.acithium.rss.ShowDescription");
     Bundle b = new Bundle();
     b.putString("title", feed.getItem(position).getTitle());
     b.putString("description", feed.getItem(position).getDescription());
     b.putString("link", feed.getItem(position).getLink());
     itemintent.putExtra("android.intent.extra.INTENT", b);

     startActivityForResult(itemintent,0);
 }

Et voici une nouvelle activité de classe qui est appelée:

public class ShowDescription extends Activity 
{

    public void onCreate(Bundle icicle) 
    {
        super.onCreate(icicle);
        setContentView(R.layout.showdescription);

        String theStory = null;


        Intent startingIntent = getIntent();


        if (startingIntent != null)
        {
            Bundle b = startingIntent.getBundleExtra("android.intent.extra.INTENT");
            if (b == null)
            {
                theStory = "bad bundle?";
            }
            else
            {
                theStory =  b.getString("title") + "\n\n" + b.getString("description") + "\n\nMore information:\n" + b.getString("link");
            }
        }
        else
        {
            theStory = "Information Not Found.";

        }
        TextView db= (TextView) findViewById(R.id.storybox);
        db.setText(theStory);

        Button backbutton = (Button) findViewById(R.id.back);

        backbutton.setOnClickListener(new Button.OnClickListener() 
        {
            public void onClick(View v) 
            {
                finish();
            }
        });        
    }
}

ici est la showdescription.xml fichier:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <ScrollView android:layout_width="fill_parent"
            android:layout_height="fill_parent" >
            <LinearLayout 
                android:orientation="vertical"
                android:layout_width="fill_parent" 
                android:layout_height="fill_parent">
        <TextView  
             android:layout_width="fill_parent" 
                 android:layout_height="wrap_content" 
                 android:autoLink="all"
                 android:text="story goes here ...."
             android:id="@+id/storybox" />
        <Button
                android:layout_height="wrap_content" 
                android:text="Back"
            android:id="@+id/back" 
            android:layout_width="100px" 
            android:layout_marginLeft="100px"/>   
        </LinearLayout>
    </ScrollView>
</LinearLayout>
Eh bien, j'ai trouvé une solution de contournement. Au début, j'avais ces classes dans un paquetage séparé, mais j'ai déménagé à tous pour le même forfait et supprimé le solde non utilisé de R fichier associé à ce paquet. Une fois que je l'ai fait, tout a commencé à travailler. Je ne dirais pas que "résolu" autant que j'appellerais une solution de contournement.
Ah! Qui l'explique! Si c'est dans un package différent, le "R" de vous référer à finit par être pas le R dont vous avez besoin! Hmm, sur la deuxième pensée qui peut ne pas être tout à fait exact... qui aurait réussi à compiler.
Ouais, je ne comprends pas non plus. Quand ils étaient dans 2 deuxième paquet, j'ai ajouté l'instruction import pour la R de fichier, mais j'étais encore en train de le pointeur null. Je pense que je vais laisser cette manière, pour l'instant. Merci

OriginalL'auteur acithium | 2010-12-28