Android :: ListActivity And SQLiteDB - Can't Refresh List
Oct 29, 2009
What is the best way to display a database queries results on the screen using ListActivity? I need the db queries to run in the background and I also need to be able to make different queries and refresh the screen according to the query result. I am using the ListActivity class with a SimpleCursorAdapter in order to display the db queries result on the screen. At the moment, I am doing the db queries at the background using AsyncTask, when getting the results I want the list to be updated immediately, but I can't find a good way to do it. It worked only when I used the changeCursor(cursor) function to set the adapter to a new cursor with the new results. But I don't think this is a good solution since it seems to stuck the UI for a while. I also found some posts about notifyDataSetChanged() but I am not sure if/how/when I should be using it with a SimpleCursorAdapter to make the view refresh.
View 2 Replies
Jun 21, 2010
I'm trying to display an image before the list in a listactivity. If I put an ImageView before the ListView, then only the list is displayed..
View 1 Replies
View Related
Oct 8, 2009
i want to know how to refresh the ListActivity when i change/add data to the list wich is dispayed.i first thougt the ListAdapter would know when the list is changed but when i add elements to the list there is no update, only when i close the activity and reopen it i see the changes.so i searched for any update() refesh() or something like that method but there is none.so it seem i didnt get the concept, can someone help me please?
View 2 Replies
View Related
Mar 18, 2009
I have a simple ListActivity midlet. It populates the list using a String array which is passed to the setListAdapter method. code...
However my question is, how is it possible to modify the properties of the list so if I know "etc" and "dev" are directories and I want to change the text colour to reflect that it is a directory how can I do this ?
Can anyone point me to any API's ?
View 2 Replies
View Related
May 31, 2010
I would like to write a rather simple content application which displays a list of textual items (along with a small pic).I have a standard menu in which each menu item represents a different category of textual items (news, sports, leisure etc.).Pressing a menu item will display a list of textual items of this category.Now, having a separate ListActivity for each category seems like an overkill (or does it?)
Naturally, it makes much more sense to use one ListActivity and replace the data of its adapter when each category is loaded.My concern is when "back" is pressed. The adapter is loaded with items of the current category and now I need to display list of the previous category (and enable clicking on list items too)
Since I have only one activity - I thought of backup and load mechanism in onPause() and onResume() functions as well as making some distinction whether these function are invoked as a result of a "new" event (menu item selected) or by a "back" press.This seems very cumbersome for such a trivial usage.Am I missing something here?
View 1 Replies
View Related
Jan 30, 2010
I have a working ListActivity class. Each of the list item consists of an ImageView and a TextView. However, when I try to replace the ImageView with ImageButton, The list becomes unselectable. The onListItemClick or any other function no longer get called when press a list item (Although the track ball can still focus a list item, but nothing more can be done). I have searched the forum and also the internet and failed to find any such working example, apart from one guy reporting a similar problem but with no answer.Code...
View 6 Replies
View Related
Jul 1, 2010
I got a ListActivity. I update the activity using onContentChanged() API. My problem is that each time I call the above API the list scrolls to the top. Is there any easy way to turn this "feature" off?
View 1 Replies
View Related
May 16, 2009
I have two cursor, one of them from contact content provider, other one from database. id fields are sycnhorinzed.i want to show them in same column with two row in list. i m think that i have to use simpleCursorAdapter, because arrayadapter and other adapters can not show two cursor in a list.
CODE:..........
So my list is not refresing/updating altough all cursors all results are updating.
View 2 Replies
View Related
Mar 7, 2010
When I add drawable resources to my project they do not show up in the list of drawables in the Reference Chooser. I checked the R file and there are references for the files.
I have tried refreshing the project, cleaning the project, and fixing project properties and nothing seems to help. Sometimes a couple will randomly show up in there, but not all of them.
The only consistent way I can get them to show up is to restart Eclipse.
Further findings:
After some trials, I found an other inconvenient work around to he issue. Turns out when importing multiple files into the project at once, Eclipse will only add the last one imported into the reference chooser. So when I imported my images one at a time, they all show up properly!
Like I said, inconvenient considering the amount of images I have left to import, but maybe with this new information it may help nail down where the issue may be and a possible fix.
View 2 Replies
View Related
Jul 24, 2010
I have a ListView that contains some data from sqllite table.the table is updated by some other process, and I would like to refresh it's data.The strange thing is that if I open another activity, then go back -it WILL refresh itself.
View 2 Replies
View Related
Aug 11, 2010
I am making a very simple dump and display app. I would like to see my newly entered data displayed on the list found on the first tab. But I don't know where to place requery();
Here is the code for the first tab. (Displays the data from DB.)
CODE:.........
I have tried doing (pseudo codes only)
CODE:........
And
CODE:............
But BOTH don't work!
View 3 Replies
View Related
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
Feb 5, 2013
I have had this problem for a while but never tried to fix it but now discovered it is not only on my GNex but also my Tab 2....
Basically i have email via virginmedia.com, which i believe is all set up correctly with POP enabled etc and my phone/Tab 2 email client set up to never delete from server. Problem is the email comes to the devices fine and i can reply, send new email etc, but if i refresh the list to check for any new email, what was already in my inbox just disappears from my device, not into the bin, just gone for good!
I have Android 4.2.1 on the GNex ans 4.1 on the Tab 2. Remember this is the general email client and I am on Virgin Media, this is not the Gmail email app, I do not use that. would really like to be able to get my email on the move without knowing I will lose it all straight away!
View 2 Replies
View Related
May 3, 2010
After implementing some Android Apps, including several Map activities, I try to refresh the activity when the GPS listener's onLocationChanged() mehtod is called. I have no idea how to tell the map activity to refresh on its own and display the new coords. the coords to store will have to be in global values, so that the location listener will have access to it. In my sample GPS-class (see code below) I just changed the text of a text view....but how to do that in map view?
View 2 Replies
View Related
Oct 26, 2009
In my ListView, I choose an Item to "Add Favorite" and I have to do some stuff work, I fill data again to refresh the List, then I implement OnScrollListener use setSelection(firstVisibleItem) to set List display right on Item was added. Are there any better way to do that. I mean like mCursor.requery() or something like that in android APIs ? Or any suggest way?
View 3 Replies
View Related
Oct 26, 2009
I'm trying to create an application that has 3 tabs. Under the middle tab should be a ListView. It starts up fine (on the left tab) but when I click the middle tab it crashes.
The other two tabs are static data specified in the main.xml file. But the middle tab, I try to create dynamically. Here's the code from the main onCreate function:
CODE:...............
Instead I appear to get an exception:
CODE:...............
ContactListActivity is defined this way:
public class ContactListActivity extends ListActivity { ...
I get the feeling that I'm supposed to create the Intent with something like Intent.ACTION_VIEW but this is where I get lost. If this is the problem, I could try stuff until it works, but I'd prefer to understand why.
Or is ContactListActivity supposed to override something ?
View 2 Replies
View Related
Feb 8, 2010
I have a problem with rotation, during my ListActivity is loading data from the network. To do it I use a background thread which recovers data and put them inside an ArrayList. While this thread works, there is Progress dialog activated in foreground. For the rotation I use the method with onRetainNonConfigurationInstance() to save my ArrayList's state. After android calls this method, I call dismiss() on the progress dialog on onStop(). Then the activity is created as new with onCreate(), but it use the getLastNonConfigurationInstance() to recover the ArrayList's state. Now, my problem. If I rotate from portrait to lanscape when the download is terminated and I see the data in portrait yet, everything is ok. If I rotate during progress dialog is showing I have two cases: 1- onRetainNonConfigurationInstance() saves the arraylist fully recovered, the thread terminates and everything is ok. 2- onRetainNonConfigurationInstance() saves the arraylist empty, i think the download isn't finished yet. The onCreate is called and my list is empty, the thread terminates, but i don't see anything in my list. If I am in this case and I still rotate from landscape to portrait now I can see my list full with all the data. Why? Where am I wrong?
View 7 Replies
View Related
Jun 30, 2009
I create a ListView in my activity and set its ChoiceMode to CHOICE_MODE_SINGLE, I also set its layout to simple_list_item_single_choice. But when i click on it onItemSelected() is never called and getCheckedItemPosition() returns -1. Why? the sample List10.java of ApiDemos uses ListActivity works well which just set the same as I done in my app. Any ideas?
View 2 Replies
View Related
Jan 13, 2010
I want to create a custom list view in my application. I want it to lay over the top of the application screen, with portions of the screen not filled by the listview showing the underlying application. I've been reading about ListActivity, how it can be started to handle item selected callbacks. I've also read about people simply inserting onClick handlers into the listview as it is drawn. I'm trying to decide the best way to proceed. Is it "dirty" to attach onClick handlers to the rows of a listview? It doesn't seem like the best approach, for instance, it only handles Touch Mode, not the DPAD clicks. This approach doesn't seem like what the architects had in mind. On the other hand, I don't see a good way that I can start a list activity and still have access to all the application variables I need. Do I pass the application in the context and refer back to it from even handlers after casting the context back to it's original class?
View 5 Replies
View Related
Jul 27, 2010
I know this may be a pretty simple question, but i am having problems trying to find what i am looking for. I have written an application that uses a listview activity. but now that i think more about it, i would like to have other items included to give the status of the app, etc that i just want to be displayed and not scrolled so it wont be entered into the database. does anyone have a good link to an example for this>
View 3 Replies
View Related
Jan 11, 2010
I have an ListActivity that I wan't to add a logo to at the top above the list but I'm unsuccessful. This is what my layout looks like at the moment.
<?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="fill_parent"> <ImageView android:id="@+id/logo" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <ListView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:drawSelectorOnTop="false"> </ListView> <TextView android:id="@+id/empty" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="@string/list_empty" /> </LinearLayout>
Then I add an drawable to the ImageView logo in onCreate. I've managed to show either the ListView or the ImageView but never both of them in the same LinearLayout. Is it possible to add other views together with a ListView?
View 3 Replies
View Related
Sep 8, 2009
I am using a ListActivity. Each list entry contains an ImageView and a TextView. I have a huge list and has been getting Out of Memory errors once I scroll through a fair amount of them. I figured I need to reduce the size of the images but I am wondering what happens to the objects once the list entry is hidden from view (as i scroll down the list). I have read somewhere that the list entry objects are automatically re-use. But what happens to the drawable images which were loaded into the ImageView? IF the ImageView object is reused, what happens to the binary image? Are they freed automatically? How do I prevent the OutOfMemory exception? I want to do something similar like the Android Market. As one scroll downwards the images are loaded and new entries are loaded. The Markey can have a long list which one can scroll down and all the way back up again without any problem. The only difference being mine throws OutOfMemory Exception. Advice anyone?
View 2 Replies
View Related
Dec 29, 2009
I have a list Activity 4 which i have extended the BaseAdapter and the getview looks like this.
public View getView(int position, View convertView, ViewGroup parent) {
View row=null;
for(int i=0;i<10; {
row = convertView;
if(row==null) {
LayoutInflater inflater = mContext.getLayoutInflater();
row = inflater.inflate(R.layout.parsed,null); }
TextView id = (TextView)row.findViewById(R.id.id);
id.setText(idvector.elementAt(position));
TextView photo = (TextView)row.findViewById(R.id.photo);....
View 4 Replies
View Related
Feb 2, 2010
I am having a problem.I want to explain in detail. 1)I am Having an TabActivity with 5 tabs. I loaded content as follows.
CODE:............
And the Problem is If i want to start activity which is not specified in tabhost in above Java code,it is going out of tabactivity. ie.,It is not coming in tabactivity.
2)But i want to have all the activities under tabActivity.
View 4 Replies
View Related
Sep 22, 2009
Problem to add an image in ListActivity...i took this code from
*http://commonsware.com/Android/excerpt.pdf* ..eventhough i m having problem...if i run it says The Application Stopped Unexpectedly.. try Again...i dont know the reason..can u tel anybody....pls point out the error in my code....
Here is my Code:
CODE:.....................
View 5 Replies
View Related
Mar 7, 2010
I have the following setup, and the empty view text doesn't show up...
CODE:..............
The layout file is:
CODE:........
String is defined as: <string name="contact_empty_help">"You don't have any contacts to display.
To add contacts, you have to:
<li><font fgcolor="#ffffffff">Go to <b>Contacts</b></font> application to create new contacts
</li>
<li><font fgcolor="#ffffffff"><b>Import from VCF file</b></font>, this is available in Contacts menu, the file most be on the root of the SD card
</li>" </string>
Since the list is empty, it should show me the text defined. I followed the example from the List8
View 3 Replies
View Related
May 16, 2010
I've been progressively expanding my UI, and I want to add a ListView in the middle of my UI. When I add it and change the activity to extend a ListActivity instead of just an Activity, I'm getting a Force Close. Using 1.5. Does a ListView not work embedded in a RelativeLayout?
CODE:.........
XML looks like this:
CODE:..........
And the listrow.xml:
CODE:.............
View 2 Replies
View Related
Jul 18, 2010
When I call intent code...
where and how do I call registerOnSharedPreferenceChangeListener
View 1 Replies
View Related
Apr 10, 2010
I am having trouble figuring out how to get my onListItemClick to work. Here is my code. package list.view;...................
View 3 Replies
View Related
Sep 18, 2009
Scoured the docs and forums, couldn't find an answer or reason why this is happening: I have a class that extends ListActivity and a View coming from XML for each row that looks like this:
<LinearLayout ...> <TextView ... /> <TextView ... />
<CheckBox ... /> </LinearLayout>
When I click on one of the items in the list, the onListItemClick() i have in my activity is not invoked. Turns out, if I comment out the CheckBox node in my layout xml, it works. I feel like there is a simple explanation that I don't know about.. maybe because CheckBox is an actual interactive widget it's overriding some click action or something?
View 2 Replies
View Related