Android :: Sectionindexer Is Not Updated When Adapter's Data Is Changed

Nov 4, 2010

I have ListView with adapter class which extends ArrayAdapter and implements SectionIndexer. The problem is section indexer is not updated when adapter data is changed. Even if i add new elements the section remain the same. I tried some options setFaseScrollEnabled(false); setFaseScrollEnabled(true); but i got IndexOutOfBounds exception. So how can i update sectionIndexer when adapter's data is changed.

Android :: sectionindexer is not updated when adapter's data is changed


Android :: Resetting ListView After Adapter's Data Changed

Nov 21, 2010

I have a list view that can display items based on internal state (it has items, and 'viewed' items). i need to be able to toggle between the two states, i do that using a simple button that change the adapter's state and the adapter then called notifyDatasetChanged(). My data DOES gets updated, however i was facing two problems:

if in the previous mode the list was partially scrolled, it stayed in that state after i changed the data set (if i was half the way down i'll be half way down in the new data set as well, this is not the behavior i want, but i cols not find a way to scroll the list manually to position 0. any ideas?

(setSelected is not exactly a solution since i DON'T want any selection i want to stay in touch mode) In my list View each item has an image that is fetched from the net, as so it's being brought using my networking manager and i send the image request ONLY if i'm in this screen for the first time OR if scroll state is idlle, i didn't want to start loading images from the getView method since if i fling the screen it may load a lot of unnecessary images. However when calling notifyDatasetChanged() the scroll listener methods are not called. i solved this one by using notifyDatasetInvalidated even though my data is not empty, is there a better way to solve this issue ?

View 1 Replies View Related

Android :: Resetting The ListView After Adapter's Data Was Changed

Nov 21, 2010

I have a list view that can display items based on internal state (it has items, and 'viewed' items). i need to be able to toggle between by two states, i do that using a simple button that change the adapter's state and the adapter then called notifyDatasetChanged(). My data DOES gets updated,

However i was facing two problems:

1. if in the previous mode the list was partially scrolled, it stayed in that state after i changed the data set (if i was half the way down i'll be half way down in the new data set as well, this is not the behavior i want, but i cols not find a way to scroll the list manually to position 0. any ideas ?

2. In my list View each item has an image that is fetched from the net, as so it's being brought using my networking manager and i send the image request ONLY if i'm in this screen for the first time OR if scroll state is idlle, i didn't want to start loading images from the getView method since if i fling the screen it may load a lot of unnecessary images. However when calling notifyDatasetChanged() the scroll listener methods are not called. i solved this one by using notifyDatasetInvalidated even though my data is not empty, is there a better way to solve this issue ?

View 2 Replies View Related

Android : Using A ListView - An Adapter - How To Use Notify Data Set Changed()

Jun 3, 2010

Just watched Google IO's "World Of ListView" presentation [1]. Awesome stuff. I think every Android dev should watch it.

One gotcha for me was to use BaseAdapter.notifyDataSetChanged[2]. I checked code that I have written more than a year ago and found that I did try to use that, but commented it out with '// doesn't work' and I use requery() instead. That is of course much slower.

I now tried to find out why I wrote that it didn't work and hoped that I am meanwhile so much wiser that it would be easier to understand the proper use of the API. So much for ambition: The effect I see is that the list is not updated after I call notifyDataSetChanged(), but works with requery() and I am not so much wiser.

What could be the issue here? I use a ResourceCursorAdapter and only implemented the bindView() Method. This method is called when I call notifyDataSetChanged() on the RCAdapter. However the method is called with a cursor that contains the stale data.

Now there was a second gotcha from the presentation that I couldn't really place. It was said that the data should be committed on the GUI thread too (before calling notifyDataSetChanged()). I couldn't place it then, but I now suspect that this may be the issue here. So the rule would be to do the commit() on the Cursor on the UI thread? I do the updates to the database using a Service. This Service runs in the background, sometimes the app is in the foreground at the same time, but most often not. So I don't see how I should commit something in a UI thread? Is this the issue here? There are two different Cursors and I could only use notifyDataSetChanged when it would be the same cursor, otherwise requery() is correct?

Is that it? Any ideas? Is somebody going to write a book "The Android SDK - The missing manual"?

View 4 Replies View Related

Android :: Getting Updated Array Of Data From ListView / Adapter

Aug 10, 2010

I must be missing something simple here.I've searched around but don't think my search query is touching on the right topics to yield results. Anyhow, what I'm after is running through the array of data I bind to a ListView after a "Submit" button has been clicked.

View 3 Replies View Related

Android :: Filtered List View With Custom Adapter Not Updated

Mar 25, 2010

I have a ListView with a custom Adapter that extends ArrayAdapter. It's ArrayAdapter of Type Artist. (There are about 1200 artists in my list). Artist is a very small class that has a name and an id. The Artist Class has toString() overridden to return just the name. I have an EditText. The EditText has an TextChangeListener where I call .getFilter().filter(chars, callback) on my adapter. In the Filter.Filterlistener().onComplete() callback i print the count and it looks really good. As i type the count decreases. So it seams everything works as advertised, but the List stays the same. I tried to call artistAdapter.notifyDataSetChanged() to force the list to redraw, but nothing happens. [see 2.)]. I am tinkering around for days now! I am desperate. Hopefully someone can have a look on my code and tell me what I am doing wrong! How can I force the list to be redrawn?

Here is what I have done:
1.) Defined a ListView and an EditText like this:
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list_search_text"
android:layout_width="fill_parent"
android:layout_height="35dip"
android:layout_below="@id/header">
</EditText>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list_search"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</ListView>

2.) Setup my ListView in the Activities onCreate():
private ListView listView = null;
private ArtistAdapter artistAdapter = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.search_artists);
artistAdapter = new ArtistAdapter(this, R.layout.row, list); // 'list' is an ArrayList<Artist>
listView = (ListView) findViewById(R.id.list_search);
listView.setAdapter(artistAdapter);
listView.setFastScrollEnabled(true);
listView.setTextFilterEnabled(true);
listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> av, View v, int position, long id) {
// do something } });
EditText txtSearch = (EditText) findViewById(R.id.list_search_text); txtSearch.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable arg0) { }
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { }
public void onTextChanged(CharSequence chars, int start, int before, int count) {
artistAdapter.getFilter().filter(chars, new Filter.FilterListener() {
public void onFilterComplete(int count) {
Log.d(Config.LOG_TAG, "filter complete! count: " + count);
artistAdapter.notifyDataSetChanged();
}});
}});
}

3.) This is my ArtistAdapter in short. I added an remove() and add() method:
public class ArtistAdapter extends ArrayAdapter<Artist> implements SectionIndexer {
private List<Artist> items;
/* other stuff like overridden getView, getPositionForSection,
getSectionForPosition and so on */
@Override
public void remove(Artist object) {
super.remove(object);
items.remove(object);
}
@Override
public void add(Artist object) {
super.add(object);
items.add(object);
} }

4.) My artist has also the toString() overridden:
public class Artist implements Comparable<Artist> {
public String uid;
public String name;
public Artist(String id, String name) {
this.uid = id;
this.name = name; }
public int compareTo(Artist another) {
return this.name.compareToIgnoreCase(another.name);
}
@Override
public String toString() {
return this.name;
} }

View 5 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 :: How To Refresh Updated Contacts In List View Using Base Adapter?

Jul 23, 2009

Currently I am working on IM, and I am facing problem during implementations. I am implementing this messenger using XMPP client and using smack API for implementing all features like contacts list, online offline status, and chat also. Prblem which I am facing:

Its my list view where I am showing contacts list
public class ContactsList extends ListActivity implements OnClickListener{
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ContactsManager manager = new ContactsManager(this); setListAdapter(manager);
} public class ContactsManager extends BaseAdapter{
private LayoutInflater mInflater; private Bitmap mainListIcons[];
private static ContactsInfo contactsInfo; public ContactsManager(Context context) {
mInflater = LayoutInflater.from(context); mainListIcons= new Bitmap[3];
mainListIcons[0] = BitmapFactory.decodeResource (context.getResources(), R.drawable.online);
mainListIcons[1] = BitmapFactory.decodeResource (context.getResources(), R.drawable.offline);
} @Override public int getCount() { return Global.contacts.size();//
contacts is vector where I am saving my contacts
} public Object getItem(int position) { return position;
} public long getItemId(int position) { return position;
} public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder; if (convertView == null) {
convertView = mInflater.inflate (R.layout.main_settings_lists_icon_text, null);
holder = new ViewHolder(); holder.mainListDisplayText = (TextView) convertView.findViewById(R.id.main_settings_lists_text);
holder.mainListDisplayIcon = (ImageView) convertView.findViewById(R.id.main_settings_lists_icon);
convertView.setTag(holder);}else{ holder = (ViewHolder) convertView.getTag();
} contactsInfo = (ContactsInfo)Global.contacts.elementAt (position);
String username = contactsInfo.getUsername(); String status = contactsInfo.getUserstatus();
if(status.equalsIgnoreCase("unavailable")) { older.mainListDisplayIcon.setImageBitmap(mainListIcons[1]);
}else{ holder.mainListDisplayIcon.setImageBitmap(mainListIcons[0]);
} holder.mainListDisplayText.setText(username); return convertView;
} static class ViewHolder { TextView mainListDisplayText;
ImageView mainListDisplayIcon;}
public class ContactsHandler implements RosterListener {
@Override public void entriesAdded(Collection<String> c) {
for(String s:c) { Log.i("ADDED Contacts",s);
} } @Override public void presenceChanged(Presence p) {
Log.i("PRESENCE",p.getFrom()); Log.i("IS Available",""+p.isAvailable());
Log.i("UserStatus",""+p.getStatus()); if(p.getFrom().contains("@") && p.isAvailable())
{ ChatManager chatmanager = Connection.getVopConnection getXMPPConnection().getChatManager();
Chat newChat = chatmanager.createChat("gulfam@imran-mehmood", new ChatHandler());
} } }

View 2 Replies View Related

Android :: Contents Of List View - Using A Cursor Adapter - Are Not Updated Refreshed

Aug 26, 2010

I have a list which shows data from a database using a cursor adapter. Using Menu option I am updating my database (inserting more rows deleting existing rows). When Menu operation completes, I want contents of list should show updated contents.

I have tried using cursor.requery(); (or explicitly querying cursor again) and using adapter.notifydatasetchanged(), but with this list of contents are not updated.

How can I refresh the contents of the list.

View 2 Replies View Related

Jelly Bean :: Note 3 Updated - Samsung Keyboard Colors Changed

Nov 21, 2013

I just did the update for the Note 3 and it changed my Samsung keyboard to a black background with white letter when prior to this update it was a light grey color background with black letters. Also is there a way to change it back?

View 2 Replies View Related

Android :: Updated Screen Data Instead Of Reading All Data From Framebuffer?

Jun 2, 2009

I just want to capture the updated screen data instead of reading all data from framebuffer. Can I get this data by what method?

View 4 Replies View Related

Android :: Notify Data Set Changed?

Feb 27, 2010

I have a list which is filled with a custom Array Adapter. I want to upload a progress bar every second, so i try to use notifyDataSetChanged in order to repaint the list but it doesn't seem to work.

View 1 Replies View Related

Android :: How To Use OnSensor Changed Sensor Data In Combination With OpenGL?

Nov 24, 2010

I have written a TestSuite to find out how to calculate the rotation angles from the data you get in SensorEventListener.onSensorChanged(). I really hope you can complete my solution to help people who will have the same problems like me. Here is the code, i think you will understand it after reading it. Feel free to change it, the main idea was to implement several methods to send the orientation angles to the opengl view or any other target which would need it. method 1 to 4 are working, they are directly sending the rotationMatrix to the OpenGl view. method 6 works now too, but i have no explanation why the rotation has to be done y x z.. all other methods are not working or buggy and i hope someone knows to get them working. i think the best method would be method 5 if it would work, because it would be the easiest to understand but i'm not sure how efficient it is. the complete code isn't optimized so i recommend to not use it as it is in your project. Code...

View 1 Replies View Related

Android :: CursorAdapter Notify Data Set Changed Doesn't Work?

Jul 1, 2010

I'm trying to clean up some code and now I'm determined to get this seemless ListView updating working...

I want my ListView to be updated when I call notifyDataSetChanged() but nothing happens... I'm also passing the autoRequery flag to true when creating my CursorAdapter.

Cursor c = FavoritesHandler.getCategoryFavorites(getSQLiteInstance(), category); m_favoriteAdapter.changeCursor(c); startManagingCursor(c);

View 6 Replies View Related

Android :: What's Best-practice Way To Update Adapter's Underlying Data?

Apr 25, 2010

I'm running into an IllegalStateException updating an underlying List to an Adapter (might be an ArrayAdapter or an extension of BaseAdapter, I don't remember). I do not have or remember the text of the exception at the moment, but it says something to the effect of the List's content changing without the Adapter having been notified of the change.This List /may/ be updated from another thread other than the UI thread (main). After I update this list (adding an item), I call notifyDataSetChanged. The issue seems to be that the Adapter, or ListView attached to the Adapter attempts to update itself before this method is invoked. When this happens, the IllegalStateException is thrown.If I set the ListView's visibility to GONE before the update, then VISIBLE again, no error occurs. But this isn't always practical.I read somewhere that you cannot modify the underlying this from another thread--this would seem to limit an MVC pattern, as with this particular List, I want to add items from different threads. I assumed that as long as I called notifyDataSetChanged() I'd be safe--that the Adapter didn't revisit the underlying List until this method was invoked but this doesn't seem to be the case.

I suppose what I'm asking is, can it be safe to update the underlying List from threads other than the UI? Additionally, if I want to modify the data within an Adapter, do I modify the underlying List or the Adapter itself (via its add(), etc. methods). Modifying the data through the Adapter seems wrong.I came across a thread on another site from someone who seems to be having a similar problem to mine: http://osdir.com/ml/Android-Developers/2010-04/msg01199.html (this is from where I grabbed the Visibility.GONE and .VISIBLE idea).To give you a better idea of my particular problem, I'll describe a bit of how my List, Adapter, etc. are set up.I've an object named Queue that contains a LinkedList. Queue extends Observable, and when things are added to its internal list through its methods, I call setChanged() and notifyListeners(). This Queue object can have items added or removed from any number of threads.I have a single "queue view" Activity that contains an Adapter. This Activity, in its onCreate() method, registers an Observer listener to my Queue object. In the Observer's update() method I call notifyDataSetChanged() on the Adapter.I added a lot of log output and determined that when this IllegalStateExcption occurs that my Observer callback was never invoked. So it's as if the Adapter noticed the List's change before the Observer had a chance to notify its Observers, and call my method to notify the Adapter that the contents had changed.

So I suppose what I'm asking is, is this a good way to rig-up an Adapter? Is this a problem because I'm updating the Adapter's contents from a thread other than the UI thread? If this is the case, I may have a solution in mind (give the Queue object a Handler to the UI thread when it's created, and make all List modifications using that Handler, but this seems improper).I realize that this is a very open-ended post, but I'm a bit lost on this and would appreciate any comments on what I've written.

View 1 Replies View Related

Android :: Load Data In Expandable List Adapter Through Scroll

Oct 2, 2009

How to load data in expandable List Adapter through Scroll .

Means I want to add data as per Scrolling in Run time.

View 1 Replies View Related

Android :: Section Indexer Overlay Is Not Updating As Adapter's Data Changes

May 26, 2010

I have implemented Section Indexer for an Adapter class which extends BaseAdapter.Now for the first launch Section Indexer is showing an overlay correctly. But when the contents of the list gets updated the Section Overlay does not get updated and gives ArrayOutOfBoundException. Now what happens is overlay gets updated but the Overlay is coming to the left top of the listview.

View 1 Replies View Related

Android :: Proper Implementation Of Changing ListView Data With Cursor Adapter

Sep 3, 2010

I have a ListView populated via a CursorAdapter. I give my user the ability to alter the data in the list. For example, the user can mark a row as being unread (the data are messages).

Suppose my user marked a row unread. Would a proper implementation mark the row in the database as read and then requery the Cursor?

View 1 Replies View Related

HTC Droid Eris :: Factory Data Reset Changed

May 24, 2010

After months of being really happy with 1.5, I ran with OTA 2.1 for about a week.... hated it! While I didn't see any outright bugs, the phone had hugely sluggish response, very poor battery life, etc. Finally decided to to the Factory Data Reset this morning, and voila - lovin' my Eris again.

Things to note:

Before Factory Data reset w/ 2.1 OTA:
- Phone uptime and awake time were almost equal (not good)
- Had the 50% without signal message
- 'Android System' always listed as top user of battery usage (60-70%)
- Even while idle, phone always felt 'warm' (like it was continually running a background process, as evidence by poor battery life)

After Factory Data reset w/ 2.1 OTA:
- Phone uptime and awake time now as expected (awaketime < uptime)
- No more 50% signal message
- Cell Standby and Phone Idle now top users of batter usage.
- Phone now cool to the touch while idle

One thing to note is even after the reset, I still had issues syncing Gmail contacts, and needed to delete the contacts cache.

While I won't conjecture about root cause, I'm hoping Google and VZ learn from this experience, as much of this mucking about is *way* beyond what most 'normal' users would put up with. My wife loves her iPhone and just laughs at me dealing with all this c**p. Besides, I can't remember the last time *she* had to reboot her phone..

View 15 Replies View Related

Android :: Random Numbers Changed / When Orientaion Changed

Aug 14, 2010

I am generating the random numbers and do some functionality with that .but when i change the orientation new random numbers are coming.But I want portrait random numbers.For this give me some suggestions.

View 1 Replies View Related

Android :: Custom Grid View With Array Adapter Out Of Sync With Backing Data

Oct 28, 2010

I'm have a custom GridView Array Adapter. The problem for me is that when the grid list gets large enough to scroll off the screen the gridview and arraylist get out of sync. For instance in my case I have code that checks if an actor is of type director the text color should be red. if you scroll up and down my list enough times all the actors text in my gridview will become red. The thing is that the Gridview appearance actually looks fine its the backing data. Here is the complete class. In the code you can see where I tried to override getItem and getItemId but that didn't fix anything. Code...

View 6 Replies View Related

Android :: Updated Version Of App Try To Restore Using Bundle Containing Older Data?

Feb 17, 2010

I'm trying to prevent the situation where an updated version of my app restores using a bundle written from a previous version of my app. In other words:

1) app v1 stops and calls onSaveInstanceState

2) app v1 saves the bundle

3) user goes to marketplace and updates the app to v2

4) user starts the v2 version of the app

5) v2 version calls onCreate passing the bundle with v1 data

Is that even possible? Do I need to worry about it?

View 2 Replies View Related

Android :: Calling ListView.setSelection Has No Effect When Called Directly After Adapter Data Was Invalidated

May 4, 2009

I have a ListView whose position should be changed automatically along with the data. So, when the adapter's data has changed (adapter is calling notifyDataSetInvalidated), I'm calling setSelection. This has no effect. If the call to setSelection is done later (e.g. in a click handler) it is working.

The second problem is, that the ListView maintains the scroll position of the list although the data is completely invalidated, that makes no sense IMO.

It looks like a call to layoutChildren before the call to setSelection does help in this case, but layoutChildren is protected.

What is the correct way to do this?

View 2 Replies View Related

Motorola Droid :: Updated Google Docs / Lost Data

Sep 9, 2010

My documents show up in the goggle docs app, however when I click it to open the document is blank. This is the case for every document I have. I just checked on my home computer and it's still there, however why doesn't it appear on my phone? I even went to the Google doc website on my phone and every document was blank. I tried restoring w/ titanium and didn't have any luck with that. I tried opening the application and clearing data, however after reassigning my accounts I still had blank documents. The title of all 15 documents shows up, but it's all blank

View 10 Replies View Related

HTC Desire :: Updated To Froyo / Anything That Requires Data Usage Not Working Properly

Aug 9, 2010

I updated my unbranded desire to FroYo, and now I really wish I hadn't. Anything that requires data not Working as previously. My email is no longer push - I have to go in and manually refresh - which takes at least 5 minutes, and in the case of my exchange email, usually results in a sync error. Twidroyd, Twitter, Peep, Facebook, all timeout whenever I want to refresh them; I may get one proper update a day, but the rest of the time, nada.

Internet is so slow now, I just give up half the time. WiFi flickers on and off, even though it's set to on all the time. Anyone got any ideas of stuff I can check, or whether I can un update - I love the aps2sd and stuff, but it's bricked the rest of my phone. It's getting to the point where I'm actually starting to dislike the phone because it just doesn't work.

View 8 Replies View Related

Android :: Changed All The Language

Aug 9, 2010

I've accidently changed all the language on my phone to spanish. How do I change it back to english

View 2 Replies View Related

Android :: Facebook App Changed?

May 1, 2010

I went to a manifest parade today, and when i went to take pictures with the facebook app the upload kept canceling and saying "could not upload picture 1 of 1" etc. so when we got home, thinking that the problem was due to a lack of 3G at the parade location, i tried to use the facebook app, and still got the "could not upload" error. my husband told me that he no longer had the "take photo" option in his facebook app, so i deleted the app and re-downloaded/installed it, and now my facebook app no longer has the "take photo" option as well.

View 3 Replies View Related

Android :: How To Know What Has Changed In An App Update?

Jun 10, 2010

On the iPhone, for app updates, there is a list of what has changed. I can't seem to find this for Android app updates. I'm assuming I'm missing something obvious, since I can't imagine why a list of updates wouldn't be included, so if anyone could point me in the right direction, that would be greatly appreciated.

View 2 Replies View Related

Android :: Best Way To Store Application Data / When Data Stored / Data Format Could Change In Future Versions?

Mar 4, 2010

I'm making an Android Java app game (although this question applies to all languages really) and hope to release the first version soon. I'm nervous about how I save data in my game. My problem is that, if in a later update, I decide to store more data or store the same data in a different way, I need to be careful I don't lose or corrupt data for users that upgrade (i.e. I want users to be able to use data created by an old version in the new version, like their high scores from before).For example, say I want to save high scores in version 1.

View 3 Replies View Related

Android :: How To Know If Somebody Has Changed Locale In Settings

Oct 27, 2010

I am writing a service in which I want to have an observer kind of thing for the phone Locale, which lets me know if any one has changed the Locale through Settings->Language & keyboard. Is there a way to do this?

View 2 Replies View Related







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