Carnal
Carnal

Reputation: 22064

Android - Tabhost (Tabwidget) issue with multiple tabs

I have five tabs in my list, you can see the three first tabs when TabActivity get started, then if I scroll to the right, the other two will also show up. Problem I have is that the next two tabs need to be tapped twice in order to start, and vice and versa for the first two tabs if the three last tabs are shown in screen.

Please, if anyone know how to solve this annoying stuff, I would be grateful.

Thanks in advance!

EDIT:

I found out that the real problem is when I scroll to end (left or right) which causes any tab to be tapped twice in order to work, someone who recognize this? I found that it can be tapped once when scrolled to the end (right or left), but only after 3 seconds. If I tap right away, it need to be tapped again to work.

My code (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>

Upvotes: 2

Views: 1285

Answers (2)

dcanh121
dcanh121

Reputation: 4695

Did you wanted to try the ViewFlipper (as in the new Android market).

Here is the entire code,

Set default page for ViewPager in Android

Upvotes: 2

zdp
zdp

Reputation: 119

It sounds like you might be losing focus on the tabs.

Have you tried to implement:

android.view.ViewTreeObserver.OnScrollChangedListener

And set the focus back on the TabHost when this is triggered?

You may also try playing with setOverScrollMode() in your TabHost

Upvotes: 1

Related Questions