2011-01-15 13 views
0

Sorry, wenn dies eine Wiederholung ist, funktionierte keine der Lösungen, die ich online gefunden habe, für mich.Android: listActivity unter Tab

Ich habe 2 Registerkarten, und ich versuche, eine Liste auf einer der Registerkarten hinzuzufügen. Hier ist der Code:

public class Library extends ListActivity { 

    ParsingDBHelper mDbHelper; 
    ListView lv; 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

     Bundle extra = getIntent().getExtras(); 
     String temp = extra.getString(Httpdwld.RESULT); 

     mDbHelper = new ParsingDBHelper(this); 
     mDbHelper.open(); 

     parsing(); 

     fillData(); 
    }  

    private void parsing() { 
     // IMPLEMENT 
    } 

    private void fillData() { 
     Cursor c = mDbHelper.fetchAllSearch(); 
     String[] FROM = new String[] {ParsingDBHelper.KEY_TITLE, ParsingDBHelper.KEY_AUTHOR, 
       ParsingDBHelper.KEY_YEAR, ParsingDBHelper.KEY_LOCATION, 
       ParsingDBHelper.KEY_CALL_ISBN, ParsingDBHelper.KEY_AVAILABILITY}; 
     int[] TO = new int[] {R.id.row_title, R.id.row_author, R.id.row_year, 
       R.id.row_location, R.id.row_id, R.id.row_avail}; 
     SimpleCursorAdapter notes = 
      new SimpleCursorAdapter(this, R.layout.row_layout, c, FROM, TO); 
     lv.setAdapter(notes); 
    } 
} 

mDbHelper ist einfach ein ein Helfer für SQLiteDatabase verwenden.

Hier ist mein XML-Code für den Tabs

<?xml version="1.0" encoding="utf-8"?> 
<TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/tabhost" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:padding="5dp"> 
     <TabWidget 
      android:id="@android:id/tabs" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      /> 
     <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:padding="5dp" >    
     </FrameLayout> 
     <ListView android:id="@android:id/list" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
     /> 

    </LinearLayout>> 
</TabHost> 

Aber ich erhalte immer "Can not Aktion starten: Bibliothek" Fehler. Hier ist, wo ich Bibliothek nennen

public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.search_result); 

     TabHost tabHost = getTabHost(); 
     TabHost.TabSpec spec; 
     Intent intent; 

     intent = new Intent(this, Library.class); 

     // Initialize a TabSpec for each tab and add it to the TabHost 
     spec = tabHost.newTabSpec("Library").setIndicator("Library") 
     .setContent(intent); 
     tabHost.addTab(spec); 

}

Irgendwelche Vorschläge?

+0

Verwenden Sie 'adb logcat', DDMS oder die DDMS-Perspektive in Eclipse, um LogCat zu betrachten und die dem Fehler zugeordnete Stack-Ablaufverfolgung zu untersuchen. – CommonsWare

Antwort

0

Ihre Aktivität muss in Ihrer AndroidManifest.xml aufgelistet werden. Ihr Logcat würde dies auch als Ausnahme anzeigen.

+0

danke, ja, ich habe es durch logcat herausgefunden – Jin

Verwandte Themen