TextViewのフォーカスを有効にする

androidのTextViewでフォーカスを有効にしようと思ったけど、うまく行かなかったのでメモ。

xmlで普通に↓「focusable」をtrueにすればいいだけかと思っていたらうまく行かなかった。

<TextView
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:text="てきすと"
  android:focusable="true"
  />

↓のように「focusable」と「focusableInTouchMode」をtrueにするとうまく行った。

<TextView
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:text="てきすと"
  android:focusable="true"
  android:focusableInTouchMode="true"
  />

「focusableInTouchMode」はTouchモード時にViewがフォーカスを取得可能か設定するオプションとのこと。



コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

次のHTML タグと属性が使えます: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>