java - Implement a ListView unclickable with two clickable buttons on every Item -
i'm trying make listview 2 buttons, need know position of list when click on button, need item become unclickable!
is there people can me ?
this item.xml:
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@color/clear"> <imageview android:layout_margintop="20dp" android:layout_marginbottom="10dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@color/clear" android:layout_centerhorizontal="true" android:id="@+id/imgproducte" android:clickable="false" android:focusable="false" android:focusableintouchmode="false"/> <textview android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/nompreuquantitat" android:layout_marginleft="30dp" android:layout_marginright="30dp" android:layout_below="@id/imgproducte" android:layout_marginbottom="3dp" android:layout_centerhorizontal="true" android:textsize="18sp" android:gravity="center" android:text="test1" android:clickable="false" android:focusable="false" android:focusableintouchmode="false"/> <textview android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@id/nompreuquantitat" android:layout_marginleft="30dp" android:layout_marginright="30dp" android:layout_marginbottom="3dp" android:textsize="16sp" android:layout_centerhorizontal="true" android:id="@+id/descripcio" android:gravity="center" android:clickable="false" android:focusable="false" android:focusableintouchmode="false"/> <linearlayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center_horizontal" android:layout_margintop="10dp" android:layout_below="@id/descripcio"> <button android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_marginright="10dp" android:layout_marginbottom="10dp" android:id="@+id/btn_menys" android:background="@drawable/b_minus" android:focusable="false" android:clickable="false" android:focusableintouchmode="false"/> <textview android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_marginbottom="10dp" android:id="@+id/quantitat" android:background="@drawable/b_buit" android:gravity="center" android:focusable="false" android:focusableintouchmode="false" android:clickable="false"/> <button android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_marginleft="10dp" android:layout_marginbottom="10dp" android:onclick="" android:id="@+id/btn_mes" android:background="@drawable/b_plus" android:focusable="false" android:focusableintouchmode="false" android:clickable="false"/> </linearlayout> </relativelayout>
and java class :
lstproductes.setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> parent, view view, int position, long id) { toast.maketext(getapplicationcontext(),""+view.isselected(),toast.length_short).show(); try { final button botoafegir = (button) findviewbyid(r.id.btn_mes); final button botorestar = (button) findviewbyid(r.id.btn_menys); final string concepte = arraiproductes.get(position).getname(); botoafegir.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { toast.maketext(getapplicationcontext(), "afegir " + concepte, toast.length_short).show(); } }); botorestar.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { toast.maketext(getapplicationcontext(), "restar " + concepte, toast.length_short).show(); } }); } catch (exception exc) { toast.maketext(getapplicationcontext(), exc.getmessage(), toast.length_short).show(); } } });
make layout (convertview in getview of adapter) mentioned in getview of adapter, make setclickable false when button in layout clicked
and mention click listeners in getview of adapter
Comments
Post a Comment