我在Activity的后代中使用listview布局,Adapter的getView实现如下,可以长按:
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
TextView tv = new TextView(CustomTitleActivity.this);
tv.setText(title[position]);
return tv;
}
return convertView;
}
但是当我尝试从这样的布局文件中膨胀项目的视图时:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/local_songs_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:focusable="false"
android:orientation="horizontal">
<LinearLayout
android:layout_weight="1"
android:focusable="false"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:focusable="false"
android:text="TITLE"
android:textAppearance="?android:textAppearanceSearchResultTitle"
/>
<TextView
android:id="@+id/artist"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="Unknow"
android:focusable="false"
android:textAppearance="?android:textAppearanceSearchResultSubtitle"
/>
</LinearLayout>
<LinearLayout
android:layout_weight="3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:orientation="horizontal">
<ImageButton
android:id="@+id/favorite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_favourite"
android:background="#0000"
android:focusable="false"
android:onClick="onToggleStar"/>
<CheckBox
android:id="@+id/select"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
android:focusable="false"/>
</LinearLayout>
</LinearLayout>
我无法单击/长按它们,我已经尝试将 android:focusable 属性设置为 false。有人可以给我一个提示吗?