[android-developers] Cannot get selector to display 'disabled' state image
I have an adapter that returns the following layout as one of the views, http://schemas.android.com/apk/res/android"; android:id="@+id/date_selector_1" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="60dip" android:background="@drawable/date_selector_bg" > This items behaves as a header row with two buttons that are clickable (one on right and one on left). These two buttons (images views) have the following drawable that determines the image based on state, arr_left.xml http://schemas.android.com/apk/res/android";> arr_right.xml http://schemas.android.com/apk/res/android";> In my code I set the left_icon and right_icon to enabled or disabled based on data and I expected the imageview to correctly select the image based on the states in the xml. To my utter frustration, the disabled images NEVER appears. I know the left and right imageviews are correctly being set to enabled and disabled because the onclicklisteners are called or not called consistent with the state of the view. I just cannot understand why the selector is not selecting the correct state images... I know I can write code to force the imageview to display the correct image but I am giving up alot of flexibility in the future if I want to change out the images the selector points to. I would really appreciate any advice on this problem... my concern is that the RelativeLayout is a view in a ListView and that the state of that view is somehow confusing the StateListDrawable for the images. Mark. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en To unsubscribe, reply using "remove me" as the subject.
[android-developers] CLOSE_WAIT status never clears
I am using the HttpURLConnection class to make my http requests to get data and I am noticing that some OS tools show my app as remaining in a CLOSE_WAIT status no matter how long I wait. Here is a sample of the code I use to make the request, URL url = new URL(strURL); URLConnection connection = url.openConnection(); HttpURLConnection httpConnection = (HttpURLConnection)connection; httpConnection.setDoInput(true); httpConnection.setDoOutput(true); httpConnection.setUseCaches(false); httpConnection.setRequestMethod(GET); int responsecode = httpConnection.getResponseCode(); if (responsecode == HttpURLConnection.HTTP_OK) { InputStream in = httpConnection.getInputStream(); byte[] buffer = new byte[bufSize]; int bufSize = 8192; int length = bufSize; while (length != -1) { // keep reading until we get -1 returned... length = in.read(buffer, 0, bufSize); } } in.close(); httpConnection.disconnect(); Is this a known issue with the platform or am I missing a step in closing the connection? Thanks, Mark -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How do I set the selected state of an item in a gallery (the correct way)
thanks Joseph... i have no idea why the selector background does not JUST WORK... I ended up having to 'force' the right backround in the onItemSelected callback and in the getView of the adpater when the position == selected position of the gallery. If anyone else knows why this is not working I would love to fix it so I did not have to write custom code to handle what the platform should be handling by default. thanks, Mark On Jul 24, 2:51 pm, Joseph Earl wrote: > Not setting anything interesting that I'm aware of. > > My getView in my adapter looks like: > > public View getView(int position, View convertView, ViewGroup parent) > { > ImageView i; > > if (convertView == null) { > i = (ImageView) View.inflate(mContext, R.layout.gallery_item, > null); > } > else { > i = (ImageView) convertView; > } > i.setImageDrawable(R.drawable.image); > // some other stuff > > return i; > > } > > And in the gallery_item layout XML file there is just an ImageView > with the selector in my earlier post as the background. > > On Jul 24, 6:59 pm, Mark Nuetzmann wrote: > > > > > I changed my selector to be exactly what you have (but using my > > drawables ;) and it still behaves the same way; no selected state. > > How are you setting the items that are being returned by the adapter? > > Are you setting anything interesting on those views that might result > > in it working for you? > > > On Jul 24, 12:45 pm, Joseph Earl wrote: > > > > I use something like: > > > > http://schemas.android.com/apk/res/android";> > > > > > > > > android:drawable="@drawable/frame_gallery_thumb_pressed" /> > > > > > android:drawable="@drawable/frame_gallery_thumb_pressed" /> > > > > > > > > > > as a background for views in my gallery which seems to work perfectly. > > > I should note that when the selected item is pressed it maintains the > > > selected state drawable (it was how I wanted it) but you could show > > > the default press state when the selected item is pressed. > > > > On Jul 24, 6:23 pm, Joseph Earl wrote: > > > > > Try moving your state_selected statement above your state_pressed item > > > > and see if it works. > > > > > On Jul 24, 6:07 pm, Mark Nuetzmann wrote: > > > > > > I have a gallery that displays TextViews where the background of each > > > > > view is the following: > > > > > > > > > > > http://schemas.android.com/apk/res/android";> > > > > > > > > > android:state_pressed="true" > > > > > android:drawable="@drawable/item_pressed" /> > > > > > > > > > android:state_selected="true" > > > > > android:drawable="@drawable/item_selected" /> > > > > > > > > > android:drawable="@drawable/item_idle" /> > > > > > > > > > > > This selector work just fine for the state_pressed and default (idle) > > > > > states, but the selected item state is never displayed. I REALLY do > > > > > not want to force the background of the selected item by changing the > > > > > background of the view when the onItemSelected event is called. What > > > > > is the correct state or correct way to get the TextView background to > > > > > be set properly. Is the selected (center) view in the gallery not > > > > > really selected? Is there some other state I should put in the > > > > > selector drawable xml? > > > > > > Thanks, Mark. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Controlling a TextView's textColor behavior
I have a LinearLayout that contains an ImageView and two TextViews that is returned by my ListView item adapter. I know this has been asked many times and I am following the advice I have found so far but have a small yet elusive problem with the color of the TextViews. The ListView has a selector set to a 9-patch drawable that puts a nice background behind the list items when selected or pressed. In the xml for the LinearLayout returned to the ListView I set the textview.textColor="@color/textview_statelist". textview_statelist: http://schemas.android.com/apk/res/android";> When I run the app and touch an item in the list everything works perfect; the text color changes with state just fine. However, after I touch the item in the list, for a split second, the text views background becomes an opaque white and NOT the listSelector of the ListView. After just a second the ListView repaints again and everything is fine, the TextView again paint with the correct background (ie, not opaque anymore). Has anyone experienced this behavior? If so, has anyone found a resolution to this? I the only thing I can think of is that I am missing some item states in the color state list xml, but the fact that the text color is changing makes think this is NOT true as it is a problem with the background of the text view and NOT the color of the text. Mark. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Controlling a TextView's textColor behavior
Note: if I just set the textColor of the TextViews to a single color I DO NOT have the problem with the background of the TextViews. It is only when I use the ColorStateList xml that this behavior is seen. On Jan 3, 3:07 pm, "mnuetzm...@handmark.com" wrote: > I have a LinearLayout that contains an ImageView and two TextViews > that is returned by my ListView item adapter. I know this has been > asked many times and I am following the advice I have found so far but > have a small yet elusive problem with the color of the TextViews. The > ListView has a selector set to a 9-patch drawable that puts a nice > background behind the list items when selected or pressed. In the xml > for the LinearLayout returned to the ListView I set the > textview.textColor="@color/textview_statelist". > > textview_statelist: > > http://schemas.android.com/apk/res/android";> > android:color="@color/white_text" /> > android:color="@color/white_text" /> > android:color="@color/black_text" /> > > > When I run the app and touch an item in the list everything works > perfect; the text color changes with state just fine. However, after > I touch the item in the list, for a split second, the text views > background becomes an opaque white and NOT the listSelector of the > ListView. After just a second the ListView repaints again and > everything is fine, the TextView again paint with the correct > background (ie, not opaque anymore). > > Has anyone experienced this behavior? If so, has anyone found a > resolution to this? I the only thing I can think of is that I am > missing some item states in the color state list xml, but the fact > that the text color is changing makes think this is NOT true as it is > a problem with the background of the text view and NOT the color of > the text. > > Mark. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en