Showing posts with label ListView. Show all posts
Showing posts with label ListView. Show all posts

Thursday, June 27, 2013

How to stop EditText from gaining focus at Activity startup? - Android


I have an activity with EditText at the top and a ListView under it.. EditText takes focus as soon as the Activity starts.. and also the soft keyboard comes up..

To fix this problem, add the following code in your enclosing layout of EditText, ListView,

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/mainLayout"
  android:descendantFocusability="beforeDescendants"
  android:focusableInTouchMode="true" >
and also remove

 <requestFocus />
from EditText.

Tuesday, December 4, 2012

Clickable links for textview inside Listview - Android

How to make a URL/link clickable in a textview which is inside a Listview?


Let us assume that you are binding your Listview to a custom adapter. In that case, the following piece of code goes into your getView method call:
Code:
textView.setText(Html.fromHtml(item.gettext()));
textView.setAutoLinkMask(Linkify.WEB_URLS);
Took me sometime to find this out :)