2012-03-06 23 views
0

次のコードをクリックするとクラッシュします。 startActivity(...)がコメントアウトされても、クラッシュすることはありませんが、動作しません。しかし、活動は空です!私は何が起こっているのか漠然としています。バンドルの取り出しは機能しません。startActivityの使用中にエラーが発生しました

誰もが考えている?

ShowDescription.java

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,ShowDescription.class); 

    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()); 
    b.putString("pubdate", feed.getItem(position).getPubDate()); 

    itemintent.putExtra("android.intent.extra.INTENT", b); 

    startActivity(itemintent); 
} 

RSSReader.java

に:私はあなたが、少なくともあなたの活動に次のように必要だと思う

import android.app.Activity; 
public class ShowDescription extends Activity 
{ 
} 
+0

例外とは何ですか? – marcinj

+0

まず、クラッシュ状況が発生した場合、スタックトレースを含めることで、エラーの内容を知ることができます。第二に、意図の中に直接ではなく、バンドルに値を入れている理由はありますか? – jsmith

+0

にはマニフェストファイルも含まれています - あなたの活動を定義する部分 – marcinj

答えて

1

protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 


    } 
0

あなたが持っていることを確認しますマニフェストファイルにShowDescriptionアクティビティを追加しました。

<application 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@android:style/Theme.Light"> 
    <activity 
     android:label="@string/app_name" 
     android:name=".MainActivity" > 
     <intent-filter > 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
    <activity 
     android:label="@string/app_name" 
     android:name=".ShowDescription" > 
    </activity> 
</application> 

をしても、シドが言ったように必ずそれが有効な活動がありますます:

0

あなたはそうのようなあなたのマニフェストに第二の活動を宣言する必要があります

import android.app.Activity; 
public class ShowDescription extends Activity 
{ 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

     //grab your Bundle stuff if you want to handle it that way: 
     String title = savedInstanceState.getString("title"); 
     //etc. 

     //Inflate/create your layouts here and set the contentview. 
     setContentView(showDescLayout); 
    } 
} 
+0

ありがとうございます。どういうわけか、私のマニフェストにいくつかのジャンクが挿入されました。私はそれを修正した。 – user802023

関連する問題