我有這段小小的代碼,我開始使用相對佈局,並且textview不再可點擊。如果有人能夠提出修復建議,那將會很棒。我張貼下面的XML。Android TextView不可點擊
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/fav_list_selector"
android:orientation="horizontal"
android:padding="5dip">
<ImageButton
android:id="@+id/pinImage"
android:layout_alignParentLeft="true"
android:src="@drawable/ic_9_av_make_available_offline"
android:layout_width="wrap_content"
android:layout_height="match_parent"/>
<TextView
android:id="@+id/favBusItem"
android:layout_toRightOf="@+id/pinImage"
android:layout_toLeftOf="@+id/transpoImage"
android:layout_centerVertical="true"
android:textSize="12sp"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:clickable = "true"
android:textColor="#000000">
</TextView>
<ImageButton
android:id="@+id/transpoImage"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/pinImage"
android:src="@drawable/ic_9_av_make_available_offline"
android:layout_width="wrap_content"
android:layout_height="match_parent"/>
</RelativeLayout>
我懷疑的TextView是因爲的ImageButton的不可點擊。非常感謝您的幫助。
嘗試添加'機器人:可點擊=「真」'的'TextView'標籤 –
是啊..我想,(它在XML也是)..不起作用。如果我將ImageButton更改爲ImageView,它就可以工作。我沒有明白。 (ImageButton可能會把它搞亂) – Guru
因爲圖像按鈕充當按鈕,而您的文本視圖與佈局相同,所以當您單擊文本視圖時,圖像按鈕單擊事件將始終佔據位置。如果你不使用圖像按鈕點擊事件,然後將其添加到它的佈局 android:clickable =「false」 android:focusable =「false」 –