widgets reloj para mejores mejor los gratis fecha descargar android android-widget

para - widget reloj digital android



ListView con widget seleccionable/editable (6)

¿Es posible utilizar un OnItemClickListener en un ListView cuando el diseño Items tiene un widget seleccionable / clicable (RadioButton, EditText o CheckBox)?


Citando el comentario # 31 en el enlace mencionado por Samuh (que me resolvió el problema):

De hecho, puede agregarlo al formato XML (si está inflado por uno): android: descenddantFocusability = "blocksDescendants".

Agregar aquí JIC esa página web está inactiva en el futuro.


Intenté muchas soluciones complejas, pero esta fue la más simple que funcionó:

Simplemente use android:focusable="false" como en:

<CheckBox android:id="@+id/fav_check_box" android:layout_width="wrap_content" android:layout_height="wrap_content" android:focusable="false" />


La mejor solución

  1. Agregar android:descendantFocusability="beforeDescendants" a listView en xml O
  2. Establecer dos atributos dados a false

me gusta

android:focusable="false" android:focusableInTouchMode="false"

A continuación, manejará los eventos listView row item child (Button, EditText, etc.) en lugar de listView.setOnItemClick.


Si algún elemento de la fila de la lista contiene una vista OnItemClickListener o OnItemClickListener entonces OnItemClickListener no funcionará.

el elemento de la fila debe tener param como android:descendantFocusability="blocksDescendants"

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:baselineAligned="false" android:descendantFocusability="blocksDescendants" android:gravity="center_vertical" > // your other widgets here </LinearLayout>


Solucioné mi problema diferente, en mi artículo tengo más de un LinearLayout así que si le das el id a tu lista de salida y configurasOnclickListener en la clase de adaptador, funcionará, solo desaparecerá el efecto original del toque. pero este enlace Hacer que LinearLayout actúe como un Botón es útil para hacer que linearlaout actúe como un botón al hacer clic

ít

<?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="match_parent" android:layout_marginTop="10dp"> <TextView android:id="@+id/txt_item_followers_name" android:layout_width="250dp" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:gravity="center|start" android:paddingLeft="15dp" android:text="Ali" android:textAppearance="?android:attr/textAppearanceMedium" /> <ImageView android:id="@+id/imageView" android:layout_width="35dp" android:layout_height="35dp" android:layout_alignParentStart="true" android:layout_below="@+id/txt_item_followers_name" android:layout_marginLeft="10dp" android:src="@drawable/puan_icon" /> <TextView android:id="@+id/txt_item_followers_mark" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/imageView" android:layout_toEndOf="@+id/imageView" android:background="@color/red_400" android:paddingLeft="10dp" android:text="25.5" android:textAppearance="?android:attr/textAppearanceSmall" /> <LinearLayout android:id="@+id/linear_one" android:layout_width="match_parent" android:layout_height="60dp" android:layout_alignParentTop="true" android:layout_toEndOf="@+id/txt_item_followers_name" android:background="@color/red_400" android:orientation="vertical"> <ImageView android:id="@+id/btn_item_followers_2b_follow" android:layout_width="100dp" android:layout_height="match_parent" android:layout_alignParentEnd="true" android:layout_marginLeft="10dp" android:src="@drawable/follow_buton" /> </LinearLayout> </RelativeLayout>

dentro del método getView

@Override public View getView(final int position, View convertView, ViewGroup parent) { View view = convertView; if (convertView == null) view = inflater.inflate(R.layout.deneme, null); final Followers2 myObj = myList.get(position); LinearLayout linear_one = (LinearLayout) view.findViewById(R.id.linear_one); // HERE WE DOMUNÄ°CATE IT linear_one.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Toast.makeText(parentActivity, "One Two", Toast.LENGTH_SHORT).show(); } }); TextView name = (TextView) view.findViewById(R.id.txt_item_followers_name); TextView mark = (TextView) view.findViewById(R.id.txt_item_followers_mark); final ImageView btn_follow = (ImageView) view.findViewById(R.id.btn_item_followers_2b_follow); name.setText(myObj.getName()); mark.setText(myObj.getScore()); /* if (myObj.isFollow() == true) { btn_follow.setImageResource(R.drawable.following_buton); } else { btn_follow.setImageResource(R.drawable.follow_buton); } btn_follow.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Followers2 myObj = myList.get(position); if (myObj.isFollow() == true) { btn_follow.setImageResource(R.drawable.following_buton); } else { btn_follow.setImageResource(R.drawable.follow_buton); } } });*/ return view; }


Es posible que desee echar un vistazo a este problema . Tener un elemento enfocable en una fila de un ListView causa que el OnItemClickListener NO se invoque. Sin embargo, eso no significa que no pueda tener elementos enfocables / clicables en una fila, hay algunas soluciones como esta .

Además, puede echar un vistazo a la pantalla Registros de llamadas. Tiene un ListView con elemento seleccionable (el icono de llamada a la derecha). Vea el código fuente aquí