【问题标题】:Android - Tabhost (Tabwidget) issue with multiple tabsAndroid - 带有多个标签的 Tabhost(Tabwidget)问题
【发布时间】:2011-10-23 19:27:46
【问题描述】:

我的列表中有五个选项卡,当 TabActivity 启动时你可以看到前三个选项卡,然后如果我向右滚动,另外两个也会显示出来。我遇到的问题是接下来的两个选项卡需要点击两次才能启动,如果屏幕中显示最后三个选项卡,则前两个选项卡反之亦然。

如果有人知道如何解决这个烦人的问题,我将不胜感激。

提前致谢!

编辑:

我发现真正的问题是当我滚动到结尾(向左或向右)时,会导致任何选项卡被点按两次才能工作,有人知道吗?我发现滚动到最后(向右或向左)时可以点击一次,但只能在 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>

【问题讨论】:

    标签: android android-tabhost tabwidget


    【解决方案1】:

    您是否想尝试一下 ViewFlipper(就像在新的 Android 市场中一样)。

    这是完整的代码,

    Set default page for ViewPager in Android

    【讨论】:

      【解决方案2】:

      听起来您可能会失去对选项卡的关注。

      您是否尝试过实现:

      android.view.ViewTreeObserver.OnScrollChangedListener
      

      并在触发时将焦点重新设置在 TabHost 上?

      您也可以尝试在 TabHost 中使用 setOverScrollMode()

      【讨论】:

      • 我自己制作了这样的滚动视图:stackoverflow.com/questions/3948934/…
      • 然后我检测滚动何时处于最右边,并在 tabhost、tabwidget 甚至每个选项卡中设置Focusable(true)。还是不行。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多