Friday, 15 May 2015

Android ListView Item not clickable -



Android ListView Item not clickable -

i've problem listview: (customized) items clickable on divider. i've looking few hours solution nil worked me.

android:descendantfocusability="blocksdescendants" dosen't work correctly. setting focusable=„false“ on each childitem dosen't work too. know solution issue?

itemlayout.xml

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:paddingtop="@dimen/padding" android:paddingbottom="@dimen/padding" android:paddingleft="@dimen/padding" android:paddingright="@dimen/padding" android:layout_width="match_parent" android:descendantfocusability="blocksdescendants" android:layout_height="wrap_content" > <textview android:layout_width="match_parent" android:focusable="false" android:focusableintouchmode="false" android:layout_height="wrap_content" style="@style/elremfontmedium" android:id="@+id/detailnoticetext" /> </linearlayout>

this ist listview

<listview android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/detailnoticelistview"/>

as adapter used cursoradapter

public class noticeadapter extends cursoradapter { public noticeadapter(context context, cursor cursor) { super(context, cursor, 0); } @override public view newview(context context, cursor cursor, viewgroup parent) { layoutinflater inflater = layoutinflater.from(parent.getcontext()); view retview = inflater.inflate(r.layout.contact_detail_notice_item, parent, false); homecoming retview; } @override public void bindview(view view, context context, cursor cursor) { textview textviewnotice = (textview) view.findviewbyid(r.id.detailnoticetext); textviewnotice.settext(cursor.getstring(cursor.getcolumnindex(databasehelper.notice_table_column_text))); } }

the onitemclick in fragmant

@override public void onitemclick(adapterview<?> adapterview, view view, int i, long l) { switch(adapterview.getid()) { case r.id.detailnoticelistview: cursor cursor = mnoticeadapter.getcursor(); cursor.movetoposition(i); textview textview = (textview) view.findviewbyid(r.id.detailnoticetext); bundle bundle = new bundle(); bundle.putstring(noticedialog.edit_text_id, cursor.getstring(cursor.getcolumnindex("_id"))); bundle.putstring(noticedialog.edit_text, textview.gettext().tostring()); noticedialog noticedialog = new noticedialog(); noticedialog.settargetfragment(this, 0); noticedialog.setarguments(bundle); noticedialog.show(getfragmentmanager(),"noticedialog"); break; } }

i've solved problem. reason modify textview style this.

<style name="elremfontmedium" parent="@android:style/textappearance.medium"> <item name="android:textsize">20dp</item> <item name="android:textisselectable">true</item> </style>

the problem <item name="android:textisselectable">true</item>. removed attribute , works fine.

android listview cursor customization

No comments:

Post a Comment