0

Ich habe eine Anwendung, in der ich eine Listenansicht anzeigen möchte, die in TabHost mit mehreren Registerkarten angezeigt wird das Problem ist, dass der Code ich verwendet wurde, um die Listenansicht zu binden i funktioniert gut, wenn nicht funktioniert mit TabHost ist hier nicht arbeitenListenansicht in TabHost Funktioniert nicht

mein Code

<TabHost 
    android:id="@+id/tabhost" 
    android:layout_width="600sp" 
    android:layout_height="wrap_content" 
    android:layout_span="3" > 

    <TabWidget 
     android:id="@android:id/tabs" 
     android:layout_width="600sp" 
     android:layout_height="fill_parent" 
     android:gravity="top" > 
    </TabWidget> 

    <FrameLayout 
     android:id="@android:id/tabcontent" 
     android:layout_width="wrap_content" 
     android:layout_height="300sp" 
     android:layout_gravity="center_horizontal" 
     android:paddingTop="40sp" 
     android:scrollbarAlwaysDrawVerticalTrack="true" > 

     <LinearLayout 
      android:id="@+id/Notebook_Tab" 
      android:layout_width="600sp" 
      android:layout_height="fill_parent" 
      android:orientation="vertical" > 

      <TableLayout 
       android:id="@+id/DesktopTabListTableLayout" 
       android:layout_width="600sp" 
       android:layout_height="wrap_content" > 

       <TableRow 
        android:id="@+id/DesktopListTableRow" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" > 

        <ListView 
         android:id="@+id/DesktopListView" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_span="4" 
         android:clickable="true" 
         android:isScrollContainer="true" 
         android:scrollbarAlwaysDrawVerticalTrack="true" 
         android:scrollbarSize="10sp" 
         android:scrollbars="vertical" > 
        </ListView> 
       </TableRow> 
      </TableLayout> 
     </LinearLayout>        
    </FrameLayout> 
</TabHost> 

und Code

public void FillGrid(String s) { 
     clsDatabase dbh = new clsDatabase(this); 
     dbh.openDataBase(); 
     Cursor cursor; 
     cursor = dbh.getGridData(s); 
     dbh.close(); 
     if (cursor != null) { 
      int cnt = cursor.getCount(); 
      if (cnt > 0) { 
       startManagingCursor(cursor); 
       try { 
       SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, 
       R.layout.desktop_list, cursor, new String[] { 
        AuditTab.KEY_ROW_ID, AuditTab.KEY_ID, 
          AuditTab.KEY_SHORT_NAME }, new int[] { 
       R.id.txt_Desktop_ID, R.id.txt_DesktopID, 
       R.id.txt_DesktopModel }); 
       adapter.setViewResource(R.layout.desktop_list); 
       lv.setAdapter(adapter); 
       lv.setTextFilterEnabled(true); 
       lv.setFocusable(false); 
       } catch (Exception ex) { 
        ex.fillInStackTrace(); 
       } 
      } 

     } 
    } 

Die obige Funktion funktionierte gut, wenn es keinen Tabhost gab, aber jetzt funktioniert es nicht und es gibt auch kein Problem, da die getGridData() -Methodenzeilen gut zurückgegeben werden, aber die Daten nicht vom Adapter gebunden werden ist wie es ist, wie es sein sollte Bitte helfen Sie mir

Antwort

0

zuerst den Inhalt des Layouts gebunden und dann binden Sie es mit Registerkarte wird es funktionieren