android - Illegal state on click imageview with background (selector) -


i have appwidget collection (listview). source widget xml layout:

<?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:background="@color/widget_list_background"     android:orientation="vertical"     android:paddingbottom="3dip"     android:paddingleft="6dip"     android:paddingright="6dip"     android:paddingtop="3dip" > <!-- header -->  <linearlayout     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:gravity="center_vertical"     android:orientation="horizontal" >      <!-- app icon -->      <imageview         android:id="@+id/widget_list_icon"         android:layout_width="32dip"         android:layout_height="32dip"         android:layout_marginright="3dip"         android:src="@drawable/airplane" />      <!-- mailbox -->      <textview         android:id="@+id/widget_list_account"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_weight="1"         android:maxlines="2"         android:text="john@foo.com"         android:textcolor="@color/widget_text_primary" />      <!-- unread count -->      <textview         android:id="@+id/widget_list_unread"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_marginright="3dip"         android:text="12"         android:textcolor="@color/widget_text_secondary"         android:textstyle="bold" /> </linearlayout>  <!-- overflow menu -->  <imageview     android:id="@+id/widget_list_overflow"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:background="@drawable/simple_button_holo"     android:paddingleft="4dip"     android:paddingright="4dip"     android:src="@drawable/toolbar_overflow" />  <!-- line -->  <linearlayout     android:layout_width="match_parent"     android:layout_height="1dip"     android:layout_marginbottom="3dip"     android:layout_margintop="3dip"     android:background="@color/widget_list_line" />  <!-- listview messages -->  <listview     android:id="@+id/widget_email_list"     android:layout_width="match_parent"     android:layout_height="match_parent" />  <!-- removed -->  <textview     android:id="@+id/widget_list_removed"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:gravity="center"     android:text="@string/widget_removed_account"     android:textcolor="@color/widget_text_primary"     android:textsize="18dip"     android:textstyle="bold"     android:visibility="gone" />  <!-- empty list -->  <textview     android:id="@+id/widget_list_empty_view"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:gravity="center"     android:text="@string/widget_inbox_empty"     android:textcolor="@color/widget_text_primary"     android:textsize="18dip"     android:textstyle="bold"     android:visibility="gone" />  </linearlayout> 

at layout exists imageview (widget_list_overflow). set imageview background: simple_button_holo

<selector xmlns:android="http://schemas.android.com/apk/res/android">      <item android:state_focused="true"           android:drawable="@drawable/simple_button_focused_holo" />      <item android:state_pressed="true"           android:drawable="@drawable/simple_button_pressed_holo" />      <item android:drawable="@android:color/transparent" /> </selector> 

issue: imageview highlights on click not on imageview, on whole layout, imageview contains. why not on click on imageview?

ps: codemagic :)

edit: (upd1) create remoteviews as:

myview = new remoteviews(packname, r.layout.mywidget);  intent svcintent = new intent(ctx, widgetlistservice.class); svcintent.putextra(appwidgetmanager.extra_appwidget_id, widgetid); svcintent.setdata(uri.parse(svcintent.touri(intent.uri_intent_scheme))); myview.setemptyview(r.id.widget_email_list, r.id.widget_list_empty_view); myview.setremoteadapter(r.id.widget_email_list, svcintent); aappwidgetmanager.updateappwidget(_widgetid, myview); 

i don't use pendingintent, set textview text , hide/show views. logcat on click empty.

hm, solution easy. add pending intent on click imageview (widget_list_overflow) , issue disappeared.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -