Por lo tanto, mi problema es que OnClickListener
no funciona cuando configuro android:clickable="true"
en mi clase.OnClickListener no funciona con el atributo que hace clic
Ésta es MyClass
código XML:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/background"
android:clickable="true">
...
...
</RelativeLayout>
MyClass.java:
public class MyClass extends RelativeLayout implements OnClickListener {
public MyClass(Context context) {
super(context);
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.book_item, this);
setOnClickListener(this);
}
public void onClick(View v) {
Log.v("TAG", "Hello");
}
...
...
}
Funciona bien cuando me puse a android:clickable
falsa. ¿Qué hago mal?
onClickListener funciona bien sin hacer clic = verdadero, pero el selector en 'android: background =" @ dibujable/fondo "' detiene el trabajo (no muestra el estado de presionar) – Scit
Establezca el estado y el oyente en la vista que debe ser clicable. Estás mezclando estados en diferentes vistas. –
¿Cómo puedo hacer eso? :) – Scit