Android - Clickable links within a scrolable textbox (DC++ clone app)
<p>Alrighty, so I'm working on a chat app for android that supports the NMDC protocol (DC++ and variants etc, available from the android market now: <a href="https://market.android.com/details?id=org.me.ADC" rel="nofollow">https://market.android.com/details?id=org.me.ADC</a>) and im trying to get it so that when someone posts a link in the main chat you are able to click that link and it opens up the browser. Ive tryed all of the suggests ive found such as using linkify or textView.setMovementMethod(LinkMovementMethod.getInstance()) and they all let me click the links but stop my abilty to scroll. Now my views are pretty complicated and nested but ill try and explain them since it will probbaly help. To start with ive got a TabHost as my root view: </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="fill_parent"
android:layout_height="fill_parent"&gt;
&lt;LinearLayout
    android:id="@+id/main_mainLayout"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"&gt;
    &lt;FrameLayout 
        android:id="@android:id/tabcontent"
        android:layout_weight="1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/&gt;
    &lt;View
        android:id="@+id/main_spacer"
        android:layout_width="fill_parent"
        android:layout_height="5dip"/&gt;
    &lt;View
        android:id="@+id/main_line"
        android:layout_width="fill_parent"
        android:layout_height="3dip"
        android:background="#A8A8A8"/&gt;
    &lt;HorizontalScrollView
        android:id="@+id/main_scrollView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"&gt;
        &lt;TabWidget
            android:tag="tabs"
            android:orientation="horizontal"
            android:id="@android:id/tabs"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#ff000066"/&gt;
    &lt;/HorizontalScrollView&gt;
&lt;/LinearLayout&gt;
&lt;/TabHost&gt;
</code></pre>

<p>all of my tabcontent obviously gets added to the tabcontent FrameLayout.</p>

<p>My Tabcontent is a ViewFlipper with two layouts in it:</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/hub_mainLayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"&gt;
&lt;TextView
    android:id="@+id/hub_hubName"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="#9E9899"
    android:textColor="#000000"
    android:text="HubName"/&gt;
&lt;ViewFlipper
    android:id="@+id/hub_flipper"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"&gt;
    &lt;include layout="@layout/hubchat"/&gt;
    &lt;include layout="@layout/userlist"/&gt;
&lt;/ViewFlipper&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p>and finally we have hubchat: </p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/hubchat_layout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"&gt;
&lt;org.me.ADC.CustomScroll
    android:id="@+id/hubchat_scroll"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"&gt;
        &lt;TextView
            android:id="@+id/hubchat_text"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/&gt;
&lt;/org.me.ADC.CustomScroll&gt;
&lt;LinearLayout
    android:id="@+id/hubchat_bottomLayout"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"&gt;
    &lt;ImageButton
        android:id="@+id/hubchat_hide"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0"
        android:src="@+drawable/arrow_down"/&gt;
    &lt;EditText
        android:id="@+id/hubchat_entry"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="textShortMessage"
        android:layout_weight="1"/&gt;
    &lt;ImageButton
        android:id="@+id/hubchat_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0"
        android:src="@+drawable/arrow_right"/&gt;
&lt;/LinearLayout&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p>Alrighty! <em>Phew</em> that was a bit of code to paste. So Finally we've got the TextView with the ID hubchat_text which is where all the actual main chat text is put. For those of you who are interested CustomScroll is just a simple wrapper around ScrollView that lets me know if it is at the bottom of its scroll or not which allows me to do things with autoscroll etc (Link to CustomScroll code: <a href="http://codepad.org/O915xqnn" rel="nofollow">http://codepad.org/O915xqnn</a>). So as i say WAY back up the top, id like to have it so when a weblink shows up in main chat i can click on it and it will open up the browser. But i need to do this without breaking the Gesture detector ive got for the ViewFlipper or the CustomScroll. Any help would be much appreciated and I'm more then happy to post any more code if it will help. So yea, help please :D
- Peter </p>
