I have spent a lot of time trying to create ListView
with clickable item that starts new activity and URL link that opens browser page.
Should be following item:
Some text [URL is here]
By clicking on Some text
new activity is starting
By clicking on [URL] web browser is starting
I tried to implement it like in here or here but anyway that doesn't work for me.
Maybe I don't set some properties which are not mentioned there.
Simple ListView:
<ListView
android:id="@+id/news_list_view_full"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:divider="@android:color/transparent"
android:dividerHeight="10dp"
android:padding="@dimen/content_padding_small"
android:layout_below="@id/news_header"/>
ListView's item:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/news_item_padding"
android:orientation="vertical" >
<TextView
android:id="@+id/news_text_view_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColorLink="@color/sosbg_orange"
android:textAppearance="@style/CustomRegularTextStyle"
android:textColor="@color/sosbg_white" />
</LinearLayout>
And adapter:
public View getView(...View view...) {
...
TextView text = (TextView) view.findViewById(R.id.news_text_view_text);
text.setText(Html.fromHtml("Hello world <a href='http://google.com'>http://google.com</a>"));
text.setMovementMethod(LinkMovementMethod.getInstance());
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// start new activity
}
}
}
So currently, link is clickable and opens browser with appropriate page
But listview's item is not clickable. As a result new activity doesn't start.
Could you please advice some steps I can try to achive result I need?