Android :: ListView Checked State Wrongly Shared Between 2 Views When Reorienting Screen

Apr 25, 2009

I have TabActivity that uses 2 other ListActivities for the tabs. Both underlying ListViews are set to CHOICE_MODE_MULTIPLE. When I run the following sequence of events, I get a strange result: 1) Setup one activity (tab) and its ListView using a CursorAdapter, including checking some items on the list 2) Reorient the screen (open the keyboard) 3) Setup the second activity (tab) and its ListView using a CursorAdapter, including checking some items on the list 4) Switch back to the first tab

At this point, I can see in Eclipse that although (of course) each ListView is a distinct object, the internal variable used to store the checked state of items, called mCheckStates, is the SAME OBJECT REFERENCE in each of the ListViews.

Clearly this is an issue, since the two views should not share the checked state of items between them.

If I skip step #2, this does not occur

Here is a bit more detail:

After Step 1: ListView1 is object reference @1, ListView1.mCheckStates is object reference @2

After Step 2: ListView1 is object reference @3, ListView1.mCheckStates is object reference @4 (the reorientation recreates the views)

After Step 3: ListView2 is object reference @5, ListView1.mCheckStates is object reference @2 <-- note the reuse of this reference from step #1, not sure how/why

After Step 4: ListView1 is object reference @3 (unchanged), ListView1.mCheckStates is object reference @2 (changed) <-- same as ListView2.mCheckStates

Android :: ListView checked state wrongly shared between 2 views when reorienting screen


Android :: Save State Of Checked Item In ListView Having Checkbox

Sep 29, 2010

I'm new to android, please help me how to save the state of checkbox,

i.e.

I've ListView with checkbox, three textview and again checkbox. I wish to save the checked state of item(s),

how to save the state of checkbox.

View 5 Replies View Related

Android :: Lost Checked State Of Check Box In ListView While Scrolling

Oct 7, 2010

I'm facing problem in scrolling. I've 20-25 items in my List, if i checked first check box, scroll down, then come up, my checked status lost (becomes unchecked), in cursor adaptor. If i use base adaptor problem is resolved but major issue with base adaptor is performance, if my list goes beyond the 100 items.

View 9 Replies View Related

Android :: Prevent Custom Views From Losing State Across Screen Orientation Changes

Aug 22, 2010

I've successfully implemented onRetainNonConfigurationInstance() for my main activity to save and restore certain critical components across screen orientation changes.

But it seems, my custom views are being re-created from scratch when the orientation changes. This makes sense, although in my case it's inconvenient because the custom view in question is an X/Y plot and the plotted points are stored in the custom view.

Is there a crafty way to implement something similar to onRetainNonConfigurationInstance() for a custom view, or do I need to just implement methods in the custom view which allow me to get and set its "state"?

View 1 Replies View Related

Android :: Changing Displayed State Of Views Based On Parent ViewGroup's State

Aug 11, 2010

I have a compound UI component built up from a ViewGroup containing a number of TextView, ImageView etc. components. Many of these have StateListDrawables as their images/backgrounds. Is there any way of making them select from this drawable based on the state of the parent ViewGroup rather than the component itself? Ideally I want to be able to change the visual state of all children of the ViewGroup (text colour, image etc) based on the state of the ViewGroup, preferably without having to hook up complex logical code. This seems like a fairly common sort of requirement, so I was hoping it would be straightforward in Android - am I going to be disappointed?

View 1 Replies View Related

Android :: Getting Checked Items From ListView Of Checkboxes

May 6, 2010

Given a listview that shows checkboxes next to a list of people, I want to be able to get the names (in Strings for example) of the people who are checked. I have set my listview mode to allow for multiple checks.

getCheckedItemPositions()

Will get the positions but I can't figure out how to iterate over the listview to get the names. Also Eclipse tells me that getCheckItemIds is not a valid method for ListView.

View 3 Replies View Related

Android :: Checked In Text / ListView Not Working

Aug 14, 2010

I have a ListView that just contains a CheckedTextView. I have a very simple CursorAdapter that populates CheckedTextViews. When I click on an item, I can see that I am responding to the correct row, store the value in my model and the CheckedText gets checked. However, when I scroll down and then back up again, while I see that the model contains the correct value (in #bindView), calling #setChecked on the CheckedTextView has no effect. Ie All items are unchecked. Code...

View 9 Replies View Related

Android :: Check A Particular Item In A Checked ListView?

Oct 11, 2010

I am using a ListView in which only one item can be checked at a time.

This is my custom list_row.xml :

CODE:..........

I populate the list in onCreate() using a normal array adapter :

CODE:............

When the list is displayed, I want to have, say the 5th item, in the list as Checked. How can I go about doing this? I know CheckedTextView has a function called setChecked(), but how can I get my 5th item from the list to apply this function on it?

View 1 Replies View Related

Android :: Retrieve Checked CheckBoxes's Items In Listview

Feb 14, 2010

Ive got ListActivity and i am using custom CursorAdapter. in each item of the list ive got also checkbox. now i have in my list screen a perm button, when you press on it, it should find all the checkboxes which are 'checked' and do some operations on the item which it's checkbox is 'checked'. how can i retrive all the checked ones? ive done focusable:false, so i can use OnClickListener, but i dont know how farther then
this..

some code:.............

View 1 Replies View Related

Android :: Wrong Item Checked When Filtering ListView

Mar 21, 2010

The problem is that when I filter the list the entries switch position in the list view. Take for example three entries: 'A', 'B' and 'C' where 'C' is checked beforehand (i.e. the entry at position 3 in the list). When I type a 'C' on the keyboard, only the 'C' entry is displayed (as intended). Now 'C' is not checked anymore, since the entry has moved from the checked position 3 to the unchecked position 1 in the list.This behavior leads to some not very welcome effects in the app. Is there a way to "move the selection with the filtering", i.e. bind the checked state to the entry and not to its initial position in the list? Or do I need to find a new approach?

View 1 Replies View Related

Android :: Show Another View On Top Of Existing ListView After Checkbox Checked

Jul 1, 2010

Currently I have a list view within it each row has a checkbox attached. I would like that once any checkbox is checked, at the bottom of the screen a view displays, and once none of the checkboxes are checked, the view automatically disappeared. Possible to do this?

View 2 Replies View Related

Android :: Setting Initially Checked CheckedTextViews In ListView For ChoiceMode - MultipleChoice

Aug 9, 2010

I am having a really difficult time trying to work with android's ListView multipleChoice mode. Here is what I am trying to do:

I have a "players" button in a game setup screen. When this is clicked it opens another activity with a multipleChoice ListView of all the players in the database in CheckedTextViews. I have this working properly and when you click on a player they will be added or removed from the game via a query to the game_players table.

The problem I am having is in setting up the ListView so that the players that have already been added to the game get checked initially when the activity opens.

I have tried to do this by iterating over the entire list in the ListView activity but this doesn't work because the Views that are not currently visible can't be accessed to check.

So now I'm trying to do this in my extended SimpleCursorAdapter in bindView but I can't even get this simple code to work:

CODE:.........

It correctly sets the player's name with setText(), but I can't get any of the boxes to check in bindView. Is there somewhere else I should be doing this or am I just doing it incorrectly?

View 1 Replies View Related

Android :: ToggleButton Won't Keep State In ListView / Why Is So?

Oct 5, 2010

Any one knows why my ToggleButtons won't keep their states in a ListView?

Each list item includes a ToggleButton - when scrolled off from the screen their states are reset to unchecked...

I presume getView() is called once they're visible; however I'm not re instantiating them anyways.

View 2 Replies View Related

Android :: Multiple Views For For Row In ListView

Jan 17, 2010

I have a ListView that could have 4 different views for a row depending on the data for the row. I have the ListView working correctly overriding getViewTypeCount and getItemViewTYpe. I originally was trying to dynamiclly update the view type count as new views were inflated by forcing calls to getViewTypeCount because it was possible that maybe one or two views may be all that would be needed. The app never functioned correctly crashing after there was more than one view added. The problem was fixed by setting getViewTypeCount to always return 4. I noticed getViewTypeCount is automatically called on app start-up and never called again unless a force call is made. So I'm just curious if this can be changed dynamically or do you need to know the number of max views you can possibly have and override getViewTypeCount to return that max value.

View 1 Replies View Related

Android :: Way To Add Multiple Views To A Listview?

Jun 15, 2010

I tried to add these views to list view using this kind of factory but everytime I try and add the view to a ListActivity, it comes up with nothing. What am I doing wrong?

View 3 Replies View Related

Android :: Disappearing Views With ListView

Jul 7, 2009

I am having a problem with ListViews. After adding a few items to the list and it becomes larger than the layout, my cancel button disappears. Scrolling and everything else on the ListView still work fine, but it replaces the views I have below it. Anyone else run into this issue? Am I missing something?

Here is an example layout:

CODE:...................

View 15 Replies View Related

Android : ListView With Different Types Of Views?

Jul 2, 2009

I'm trying to make a ListView when every item in that list can be a different type of View. for example the list could be: 1. TextView 2. ImageView 3. MyCustomView

I understands that in order to make a list I need to use an Adapter. the problem is that the Adapter uses a single layout for all of the list items, which will not support the different views.

my goal is to make an abstract View list when I can dynamically add and removes items in that list (each item is a View or subclass of it).

View 4 Replies View Related

Android :: Unwanted State Changes Of CheckBoxes In ListView

Apr 30, 2010

I am facing a very mysterious Problem. I am using a ListView with CheckBoxes that can be clicked to select people. The row layout is the following:

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content"> <CheckBox android:focusable="false" android:onClick="onSelectPerson" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_vertical" android:layout_marginRight="5dip" android:layout_marginLeft="5dip"/> <TextView android:id="@+id/person_name" android:text="test" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_vertical" android:textSize="18dip" android:layout_marginLeft="5dip"/> </LinearLayout>

As long as the amount of rows doesen't exceed the screen size (-> no scrolling) everything works just fine. But as soon as I have more rows then the screen size (-> some rows are hidden and have to be scrolled to). I have a very mysterious phenomenon: If I check the top row and scroll down some of the previously hidden rows are randomly checked too. If I scroll up again, again some of the before hidden rows are randomly vhecked (the CheckBox I clicked in first place may or may not still be checked). Also the registered onSelectPerson callback is only called for the CheckBoxes I really click. The other CheckBoxes just change their state to "checked" without calling the callback method. I have the same phenomenom on the Archos IT 5 and the Nexus One. This must have something to do with the ListView implementation but I can't quite figure out what the problem is.

View 7 Replies View Related

Android : How Can I Maintain ListView Item State?

Oct 6, 2010

My ListActivity is bound to an ArrayAdapter where I have overriden the getView() method. If I change the visibility of a widget in that method or modify the view's background color, those changes somehow get lost once that modified list item returns after being scrolled off the screen. In fact, some other view in the list is picking up the changes. How do I get the modified view to look the same when it's redisplayed after scrolling?

View 1 Replies View Related

Android :: Custom Listview Background Focus State Not Working

Jun 18, 2010

I am trying to create custom background selector for my ExpandableListView. It works fine for all states other than focused. I am unable to identify which row is currently focused. Here is the code...

View 2 Replies View Related

Android :: Selected State Of WebView In A ListView Does Not Show Selection

Feb 3, 2009

Is there a way to show that a WebView item contained as a item in a ListView is selected? Right now the WebView does not seem to display its contents transparently like every other control so it takes up the entire view and does not show its state as selected.

Also, when the content of the WebView is selected, scrolling down with the track back does not seem to cause the WebView to loose focus. If I continue to scroll down with the track ball, all of a sudden an item in the middle of the ListView gets selected.

View 3 Replies View Related

Android :: Listview / Arrayadapter With Rows Containing Multiple Text Views?

May 27, 2009

I want to create a listview with rows that have an image and two textviews. This must be a very common activity but I can't find a class/or source code that does this.

View 9 Replies View Related

Android :: ListView Animation Of Views Inside Adapter That Got Updated

Aug 29, 2010

Im using ListView to to show some custom data, once data is updated in the adapter i call notifyDatasetChanged(), so the view will get updated, all of this works well, my issue though is i would like to run an animation once only on items that got changed when the adapter was updated. currently i keep a copy of all the changed objects and i tried to animate the correct items through the getView() call.

However if i do it only once for every getView call then i see no animation most of the time on items that changed. if i continue to do so in successive getView calls i see animation on items that don not change as well and also the ones that changed get animated again and again.

Im guessing sometimes android calls the getView() for other reasons than showing the generated view immediately, and thats the reason it doesnt work if i do it once.

View 1 Replies View Related

Android : Restore Last Values Of Listview And Other Views After Coming App From Foreground?

Oct 14, 2010

When i click home button and then come back to to my application it doesn't show the last values on the listview or any other view it just look same with when i started the application.I believe it is can be done with onResume and onPause but i couldn't find how.

View 3 Replies View Related

Android :: Droid Save Checkbox State In ListView With Cursor Adapter

Mar 9, 2010

I cant find a way to save the checkbox state when using a Cursor adapter. Everything else works fine but if i click on a checkbox it is repeated when it is recycled. Ive seen examples using array adapters but because of my lack of experience im finding it hard to translate it into using a cursor adapter. Could someone give me an example of how to go about it.code...

View 3 Replies View Related

Android :: Views And Their Child Views - How To Avoid The Ugly - Boxes - When Child Views In A View Has Another Color Than Background

Jan 6, 2010

I have a simple ListView and on that ListView I have placed a number of custom defined Views. The CustomView has ImageView and two TextViews.

The CustomView also has a "stateful drawable" as background, so that the background image (a 9-patch) changes if you press the Row in the ListView. When pressing the Row, the background image changes to a Red-ish thing.

The problem is that when the background changes from the default greyish, all the Views in the CustomView (ImageView and TextViews) still have their greyish background and thus creates very ugly greay boxes on top of the now redish background.

What is the best way to solve that problem? I hoped that such things were handled automatically (as it is done in for example .NET), but I was wrong it seems.

View 1 Replies View Related

General :: How To Re-grant App Permission As Wrongly Denied

Jul 21, 2012

how I can re-grant the app permission as wrongly denied... Try to re-install the app but still unable to get the SuperUser allow to grant. Is that means once denied one app, then this app will never be get the permission fever ?

View 2 Replies View Related

Android :: Screen On/Off State?

Nov 3, 2009

I have an app that runs in the background indefinitely provided there is work to be done. I want the app to go to sleep if there is no work to be done and the user is idle. The second part has me stumped. On Windows Mobile I was able to poll the power state to determine user idleness. On BlackBerry I was able to poll the device idle time. However, there does not appear to be a way to determine user idleness on Android.

Instead of polling for user idleness directly, I thought I might be able to use the on/off state of the screen. There are 2 intents ACTION_SCREEN_OFF and ACTION_SCREEN_ON and I was able to setup a listener for these (BroadcastReceiver). The problem is that I do not know how to determine the current state of the screen at the time I register the listener, therefore I have to wait until the next screen on/off change to know anything. The docs speak of some intents that are "sticky" and thus will allow the current state to be determined, but the screen events do not appear to have that property. What am I to do?

In general, I find the lack of support for polling system state properties (e.g. screen state, power state, signal strength) in Android to be annoying. It's cool that one can listen for changes in system state rather than constantly polling for them, but one still needs to know the current state of the property at the time the listener is registered.

View 10 Replies View Related

Android :: Phone State Listener State Transitions

Feb 8, 2009

I'm a little confused by what I'm seeing with regards to phone state transitions via the PhoneStateListener. When I receive a call, this is what happens: (call comes in) RINGING -> IDLE (I pick up) OFFHOOK (I hang up) IDLE It's that first transition from RINGING to IDLE without any interaction from me (not ending the call, not answering the call) that confuses me. Do I really have to implement an idle counter to know that an incoming call has really ended? Seems like the reported phone state represents some sort of phone state that isn't the obvious one.Is this a bug or am I just not in tune with the paradigm here?

View 2 Replies View Related

Android :: Screen Freezing After 3 End Key Press In Unlocked State

Mar 7, 2010

After the animating logic implemented in powermanagerservice.java file this issue is observed.

Problem: In unlocked state(no call guard screen) press three time end key. Sceen is getting freezed i.e phone is not accepting any touch events.Screen is getting blurred and lines are getting shown.Keep the phone like that and whole screen goes for a toss.

However if you press end key again.Phone is getting back to normal state and starts taking touch events.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved