Note that there are some explanatory texts on larger screens.

plurals
  1. POTab host autoscroll – Programmatically
    text
    copied!<p>I want to develop an application simulating the tab browsing like Dolphin HD. Below is the XML file I have used to create the UI.</p> <p>My queries are,</p> <ol> <li>I am not able to get the fixed size tab like dolphin HD. </li> <li>When I have created around 4-5 tabs, now I want to programmatically set the focus to new tab and scroll it to the current view.</li> </ol> <p><img src="https://i.stack.imgur.com/jOjFP.jpg" alt="enter image description here"></p> <p>Similar query was posted in the below link, but its not working still… <a href="https://stackoverflow.com/questions/6131218/android-programmatic-scrolling-of-tabwidget/6131550#6131550">Android - Programmatic scrolling of TabWidget</a> </p> <p>In add new tab method, I tried inserting the below lines as mentioned in the above link…. but it didn’t work…</p> <pre><code> tabHost.setFocusableInTouchMode(true); tabHost.setCurrentTab(z); tabHost.setFocusable(true); //Vinod for ( i = 0; i &lt; z; i++) { getTabWidget().getChildAt(i).setFocusableInTouchMode(true); } </code></pre> <p>XML file:- </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="wrap_content" android:layout_height="fill_parent"&gt; &lt;LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5dp"&gt; &lt;RelativeLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content"&gt; &lt;HorizontalScrollView android:layout_width="420px" android:id="@+id/tab1" android:layout_height="wrap_content" android:fillViewport="true" android:scrollbars="none"&gt; &lt;TabWidget android:id="@android:id/tabs" android:layout_width="10px" android:layout_height="wrap_content" android:tag="tabPane"&gt; &lt;/TabWidget&gt; &lt;/HorizontalScrollView&gt; &lt;ImageButton android:background="@android:color/transparent" android:layout_marginTop="10px" android:id="@+id/add_btn" android:layout_height="70px" android:layout_width="70px" android:src="@android:drawable/ic_menu_add" android:layout_toRightOf="@id/tab1"/&gt; &lt;/RelativeLayout&gt; &lt;RelativeLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content"&gt; &lt;EditText android:id="@+id/address_bar" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_marginTop="10px" android:layout_width="fill_parent" android:layout_height="70px"/&gt; &lt;/RelativeLayout&gt; &lt;FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="2dp" /&gt; &lt;/LinearLayout&gt; &lt;/TabHost&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload