Android :: ListActivity Design / Changing Content Of List Adapter

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?

Android :: ListActivity design / Changing content of List Adapter


Android : Turn List Scrolling Off When Calling On Content Changed In ListActivity

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

Android : Database Adapter Design / Want To Access SQLite DB

Oct 16, 2010

I'm developing an Android application with a database. That database will have more than three tables. Now I'm working on a class called DBAdapter to access the SQLite Database. DBAdpater will have five methods for every table on database (insertEntry, removeEntry, getAllEntries, getEntry and updateEntry). So, if I have five table, DBApadter will have more than twenty-five methods. I think is so huge. How may DBAdapter classes should be?

View 1 Replies View Related

Android : Sqlite Open Helper Db Adapter Design

Jul 27, 2009

I am writing an app that has a single database file with 3 tables ( AudioTable, PeopleMap, ImageTable) and am looking at 2 design alternatives:

1. A -single- database adapter (myDBAdapter.java) which uses a database helper class that extends SQLiteOpenHelper. The adapter class has separate methods for accessing and updating rows in each of the 3 tables. ie. insertAudio() insertPeople() insertImage()

2. 3 different database adapters for each table all using the same db file.. 1. audioDBAdapter.java, 2. peopleDBAdapter.java, 3. imageDBAdapter.java) Each adapter uses it's own db helper class (extending SQLiteOpenHelper)

While option 2 offers better encapsulation of the 3 classes (and corresponding data), I'm wondering if there couldbe a performance overhead or does the SQLiteOpenHelper implementation handle this without much overhead ?

Or is there some other way I can get better encapsulation with option 1. something similar to the way the Contacts Provider nicely allows for separate instances of Contacts.People, Contacts.Phones, Contacts.Settings, etc.

View 2 Replies View Related

Android :: Changing A Divider With SetDivider In A ListActivity Without A Custom ListView?

Oct 29, 2010

I can't seem to get a customized divider, using a Drawable I've defined, to work when using a ListActivity and not creating a custom ListView. It almost seems like when the VM creates its own ListView for me, with the ListActivity, it uses a theme with the default divider provided; and if I try to provide one, no dividers appear in the ListView at all.

I know that I can create a custom ListView using XML and define android:divider on that ListView, and this does recognize my custom divider Drawable. But I would prefer to just let the ListActivity create its own ListView, if I can figure out how to get my own divider working on it.

Here's the code I'm using now:

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

View 1 Replies View Related

Android :: Changing Spinner Layout / Design

Jan 14, 2010

I am trying to modify the design of Spinner widget. I can change the background, but I can't find a way to change the arrow icon on the right side. Is there a way to do it?

View 3 Replies View Related

Android :: Modifying Adapter Content From Background Thread

Sep 14, 2010

I've read up quite a bit on the exception thrown while using BaseAdapter, but i can't seem to find an alternative solution: Make sure the content of your adapter is not modified from a background thread. What i want to achieve is to keep a copy of a message queue in memory, and use this message queue to populate the BaseAdapter for my ListView. The reason im doing this is that the message queue will keep getting messages from a socket even when the ListView is not currently present (for example a chat window).

The problem comes when i have the Activity with the ListView in foreground, BaseAdapter binded to the message queue's data, and a message comes in the socket. Adding the new message into the queue will throw the exception mentioned above. Unless i pre-populate my BaseAdapter with the message queue (as in the BaseAdapter having its own message queue) and updating both of them when a new message come in, i can't really find a way around this issue. I don't really want to double up the effort on keeping those 2 queues up-to-date like this, surely there is a better way of doing this? Send broadcasts around doesn't work either because of the potential delay in the adapter serving a scroll and the notifyDataSetChanged call is made.

View 1 Replies View Related

Android :: Design For Droid Apps Ever-changing Screen Dimensions?

Aug 2, 2010

I'm a web designer by nature, accustomed to changing resolutions and font sizes, but I'm unsure how to design for the Android platform without knowledge of screen sizes, especially when the screen rotates from portrait mode to landscape.

Should I just do generic things that tile, or is there a way to design things of static size?

By this, I mean for the GUI and graphics, not element nodes of the XML.

View 1 Replies View Related

Android :: Display Image Before The List In Listactivity

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

Android :: Update ListActivity When List Data Changes

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

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 View Related

Android :: Modify Properties Of A List In ListActivity?

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

Delay Showing Content In Fragment Pager Adapter

Jul 3, 2013

I'm using FragmentPagerAdapter has 5 tabs. In tab number 3 I'm showing data in listview from web service and it showing successfully. When I swipe to tab 2, 4 and return to tab 3, the data is still showing in listview. If I swipe to tab 1, 5 and return to tab 3, the data delay to appearing some seconds.

* In TabFragment class I'm calling AsyncTask class called "GetTopNotifications". like this coding:

[HIGH]
public static class TabFragment extends Fragment
{
public static final String ARG_OBJECT = "object";
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)

[Code]...

View 4 Replies View Related

Android : ListActivity - View Content Is "disappearing"

Oct 12, 2010

I'm having a problem with my ListView in a ListActivity with a Custom ArrayAdapter.

When the ListActivity becomes hidden (paused, whatever), the data that was present in the ArrayAdpater seems to go away. Rotation works fine, but I am only assigning the array in the ArrayAdapter in the onCreate(), nowhere else. The array is stored in a global static so the array itself should be fine. but the ListView seems to be pitching the array somewhere after the onCreate in the Activity Lifecycle.

I'm thinking the array should be re-assigned on one of the onResume(), onStart() or onRestart(), but I'm looking for a more concrete reason as this happens only rarely and never with my Cursor based Adapters.

View 1 Replies View Related

Android :: Integrate ImageButton With ListActivity Failed - List No Longer Selectable

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

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

Android :: Id Column In List Adapter

Feb 2, 2009

I am trying to use a list adapter. While querying, i need to have a column called "_id" which helps to scroll through the database. I have an other primary key in this table. Can I use a custom column name, or am i bound to the "_id" column.

View 3 Replies View Related

Android :: Looking For List Adapter Pattern

Nov 15, 2010

I have a custom layout with a lot of Views. Currently, I build the entire view hierarchy in the on Create, though I stream the actual work in small batches. This works OK up to about 1000 Views and then performance degrades a little. Obviously, I'd like to use the List Adapter pattern and only generate the parts of the View hierarchy that are visible on the screen. My parent View, however, is not (and cannot be) any of the existing List View types. My question, then, is how do the List View types interact with a List Adapter to limit the number of Views necessary to represent a big list? More broadly, is there a pattern out there for extending a Linear Layout to create special List Views?

View 4 Replies View Related

Android :: Changing The Content Of A ListView

Jun 10, 2010

I have added a menu to ListView Activity and wanted to allow the user to select the information that would be displayed in the ListView. So for example:

The ListView is populated in the onCreate method.
The user selects an option in the menu.
Upon the user making this selection the ListView would be populated with a different array.

Is onResume() executed after the menu is closed? I would test this but I am not currently home.

View 1 Replies View Related

Android :: How To Get Selected Item From List Adapter?

Aug 28, 2009

How i get the Selected item from the list Adapter.In this above code if i selected March from the Dropdown Adapter means then how can i retrieve the Manth March to show in a textview.

View 5 Replies View Related

Android :: Get A String From And SD Card Into A List Adapter?

Nov 5, 2010

I have been playing around with a LazyList code sample which is pretty neat for displaying images in a safe and non-memory-hogging way. It uses a very simple mechanism of displaying images based on a list that exists within the class file.

Example:

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

I am trying to load these values from an index file that is downloaded to the SD card, and then loaded from it. Here is the code that loads the index file and simply displays it as a Toast message (this works fine).

PULL FILE FROM SD CARD

CODE:.........

What I am struggling with is how to take this string that is being loaded from the SD card and pass it into the list adapter.

The code presently looks like this:

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

I am trying to reload or refresh that same adapter using the values I pulled from the SD card file, presently called "readString".

Can anyone give me some pointers? I am leaving out the code that I created that doesn't work ... because I don't think I am handling this at all correctly. Also - go easy on my, I am a complete newbie to all of this. :-)

Here is my what I am trying to do. Simply copy and paste the working code where I want it. I know it's not that simple, but I am having a hard time reconstructing it properly. Here is my edited code ...

PULL FILE FROM CARD ATTEMPT #2

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

The error that I get on "adapter=new LazyAdapter(this, readString);" is "The constructor LazyAdapter(new View.OnClickListener(){}, String) is undefined".

Having not shared the contents of LazyAdapter, that information may not be helpful. So here is the LazyAdapter class in it's entirety ...

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

View 1 Replies View Related

Android :: Changing Tab Content With Intents Dynamically

Jul 21, 2009

I have a tabactivity with several tabs. They are all defined with intents. On one tab, I have an action that needs to bring me to another tab and with a specific data. I worked with Intents and I broadcast them to change the tab. For that I have no problem. But I am facing an issue as soon as I try to reset my tabs for the second time (when the application starts, my method does not fail while called for the second time it hrows an exception). The issue comes only If I call the clearAllTabs() method on TabHost. Here is the exception:..........................

View 2 Replies View Related

Android :: Changing Content Of .apk Archive At Run Time

Nov 27, 2009

it is allowed to change the content of a file in the .apk archive at runtime? because the signature of the application will change.

View 2 Replies View Related

Android :: Changing Content Of Activity Run Time

Jul 24, 2010

I created an activity by using a layout written in a XML file. I would like, in response to some events, to change the content of this activity. I would like to show a VideoView over the content. In response to some other event, I may want to go back to the first content. Would it be possible to switch the content of the activity this way without running another activity (I have another technical difficult in doing that)? I tried using setContentView( videoView), and then switching back with setContentView(T.layout.main), but it seems that, when going back to the main layout, all my buttons and text boxes are created again as they were new. Would it be possible to go back to the last state of all the controls?

View 4 Replies View Related

Android :: List View Separators Using A Cursor Adapter

Oct 5, 2010

I have a ListView which is populated using a CursorAdapter. I'd also like to have some separators in my ListView. I have accomplished this with an ArrayAdapter, but I'm not sure how to accomplish this with a CursorAdapter. Are there any strategies for doing so? Or am I out of luck?

View 1 Replies View Related

Android :: Simple Cursor Adapter - List View

Jun 9, 2010

I have table with 3 columns which is binded to an XML document with three text views.

CODE:........

Depending on the value store in the third column, I have to decide whether i should display this row or not

How should, I go about with this.

This is what I have so far :

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

View 2 Replies View Related

Android : Want To Display As List View - Using Simple Adapter

Jul 12, 2010

I am calling one webservice.Result of webservice I am storing in an Array list. Result of webservice I want to display as list view. For ListView I am using SimpleAdapter. and SimpleAdapter is something like this:- SimpleAdapter adapter = new SimpleAdapter(this,hashmap, layout, from, to);

I am not able to put array list into hashmap. Is there anyway to do this?

View 2 Replies View Related

Android : Get A Controls Id From A Custom List Adapter In Droid?

Sep 10, 2010

I have a custom list adapter contains a layout with controls in it. I was wondering how I can get each individual controls id? I am planning on changing the color of some textviews. code...

View 1 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 :: How To Force A Line Break In Xml Layout When Using List Adapter

Jul 13, 2009

I am struggling with applying a forced line break in the xml layout when using a simple list adapter. The data for the list adapter is being pulled from an sqlite db.

Here is the code:

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

And here is the R.layout.item xml:

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

View 2 Replies View Related







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