android - My setOnItemClickListener from a list doesn't works -
i have list view diferents items. can load list these items when try use setonitemclicklistener method, doesn't works. press other @ pant, how method didn't exist. method , @ end of oncreate:
mylist.setonitemclicklistener(new adapterview.onitemclicklistener() { public void onitemclick(adapterview<?> parent, view view, int position, long id) { string nam=((filmsitems)parent.getitematposition(position)).getname(); intent = new intent(this, film_information.class); i.putextra("name", nam); startactivity(i); } });
what it's wrong in cod? need else? help
i add oncreate , log
protected void oncreate(bundle savedinstancestate) { setrequestedorientation(activityinfo.screen_orientation_portrait); requestwindowfeature(window.feature_no_title); super.oncreate(savedinstancestate); setcontentview(r.layout.layout_film_list); pdia = new progressdialog(this); pdia.setmessage("cargando centros..."); pdia.setcancelable(false); pdia.show(); bundle bundle = getintent().getextras(); name= bundle.getstring("name"); list = (listview) findviewbyid(r.id.listfilm); lista.setvisibility(view.invisible); loaditems(); mylist.setonitemclicklistener(new adapterview.onitemclicklistener() { public void onitemclick(adapterview<?> parent, view view, int position, long id) { string nam=((filmsitems)parent.getitematposition(position)).getname(); intent = new intent(this, film_information.class); i.putextra("name", nam); startactivity(i); } }); }
the log
06-04 10:26:20.109 6000-6000/com.example.kohario.newofersalud d/viewrootimpl﹕ viewroot touchdown(absolute) down (314 , 221)
i add xml files:
list
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margintop="3dp" android:background="@drawable/ex_fondo_degradado" android:orientation="vertical" > <listview android:id="@+id/listfilm" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="@android:color/transparent" android:divider="@android:color/transparent" android:dividerheight="3dp" android:drawselectorontop="false" android:clickable="true"/> <linearlayout android:id="@+id/listavacia" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margintop="3dp" android:gravity="center_vertical" android:orientation="vertical" android:visibility="gone" > <textview android:id="@+id/sinconexion" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:text="se ha producido un error. revise su conexión internet y vuelva intentarlo.\n\nsi el problema persiste podría tratarse de un problema temporal interno, en cuyo caso le rogamos que lo intente más tarde.\n\nreintentar" android:textcolor="@color/grisofersalud" android:textsize="16sp" android:visibility="gone" /> <imageview android:id="@+id/refresh" android:layout_width="match_parent" android:layout_height="wrap_content" android:src="@drawable/icono_refresh" android:visibility="gone" /> <textview android:id="@+id/sindatos" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:text="no se han encontrado centros con los filtros indicados. por favor, cambie sus preferencias de búsqueda e inténtelo de nuevo.\n\natrás" android:textcolor="@color/grisofersalud" android:textsize="16sp" android:visibility="gone" /> <imageview android:id="@+id/atras" android:layout_width="match_parent" android:layout_height="wrap_content" android:onclick="atras" android:src="@drawable/icono_atras" android:visibility="gone" /> </linearlayout>
item:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/base_fila" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <linearlayout android:layout_width="wrap_content" android:layout_height="match_parent" android:background="@color/azulofersalud" android:gravity="center_vertical" android:orientation="vertical" > <imageview android:id="@+id/iconolista" android:layout_width="40dp" android:layout_height="40dp" android:paddingleft="5dp" android:paddingright="5dp" android:src="@drawable/ic_action_place" /> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/transparent" android:orientation="vertical" > <textview android:id="@+id/nombre" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/verdeofersaludtrans" android:gravity="center" android:paddingbottom="2dp" android:text="elemento x" android:textalignment="center" android:textappearance="@android:style/textappearance.windowtitle" android:textcolor="@color/blanco" android:textsize="26sp" /> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:background="@color/blanco" android:orientation="vertical" android:layout_gravity="center"> <button android:layout_width="200dp" android:layout_height="27dp" android:text="ver información y tarifas" android:textsize="15dp" android:id="@+id/masinfo" android:textappearance="@android:style/textappearance.windowtitle" android:textcolor="@color/blanco" android:background="@color/accent_material_dark"/> </linearlayout> </linearlayout>
if row item of list contains focusable
or clickable
view onitemclicklistener
won't work.
the row item must have param android:descendantfocusability="blocksdescendants"
.
it's option put listener in adapter getview(int position, view convertview, viewgroup parent)
Comments
Post a Comment