2011-10-23 54 views
2

我有五個標籤在我的列表中,當TabActivity開始時,您可以看到三個第一個標籤,然後如果我滾動到右側,其他兩個也會出現。我遇到的問題是,如果最後三個選項卡顯示在屏幕中,則需要輕敲兩個選項卡才能啓動,而對於前兩個選項卡則反之亦然。Android - Tabhost(Tabwidget)問題與多個標籤

請,如果有人知道如何解決這個煩人的東西,我將不勝感激。

在此先感謝!

編輯:

我發現真正的問題是,當我滾動到結束(左或右),這導致任何標籤可挖爲了工作兩次,別人誰認識到這一點?我發現滾動到最後(左側或右側)時可以點擊一次,但只能在3秒後點擊。如果我馬上點擊,需要再次點擊才能工作。

我的代碼(XML):

<?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"> 
    <HorizontalScrollView 
     android:id="@+id/scroll" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:scrollbars="none"> 
     <TabWidget 
      android:id="@android:id/tabs" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="#000000"/> 
    </HorizontalScrollView> 
    <FrameLayout 
     android:id="@android:id/tabcontent" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" /> 
</LinearLayout> 

回答

1

這聽起來像你可能會在標籤上會失去焦點。

您是否嘗試過實施:

android.view.ViewTreeObserver.OnScrollChangedListener 

,並設置焦點放回TabHost這個被觸發時?

你也可以嘗試在你的TabHost與setOverScrollMode()打

+0

我做我自己的滾動型是這樣的:http://stackoverflow.com/questions/3948934/synchronise-scrollview-scroll-positions-android – Carnal

+0

然後我檢測滾動是最充分的權利,我setFocusable(真)在tabhost,tabwidget,甚至在每個選項卡。仍然不起作用。 – Carnal