Paul,

And on your old questions 1 and 2 - I wouldn't use ArrayAdapter, it's too basic, a nice way to start, but really doesn't have much flexibility for complex data types.

If you wanted to use a cursor-based adapter, you'd most likely need to import your data from files into a database.

A hybrid design is also possible - a ContentProvider that keeps a reference to the data file for each item, and possibly also contains the item's title, so it has everything necessary for presenting your item list. You'd then be able to take advantage of the content framework's data change notifications (such as your list automatically refreshing when items are added / deleted).

Also not sure why you're not using a database for all your data (as opposed to separate files), but that must be some kind of incoming requirements constraint, so not going to comment on that.

-- Kostya

25.01.2011 19:09, Paul пишет:
More thoughts... In terms of the ArrayAdapter in the parent activity,
and being able to edit/add/remove items from it in child activities,
would adding add, remove public methods to the parent activity that
then call the corresponding add/remove for the array adapter seem like
a valid way to tackle this?

Thanks,

Paul

On Jan 24, 10:20 pm, Paul<[email protected]>  wrote:
Hi all.  I need some advice on how to best proceed.

First, a little background.  I have an application that uses a
ListView as it's main activity to display all of the XML files from
the /data/data/package.name/files directory.  There may be hundreds of
these files as the app gets used, so I pass the job of scanning the
directory and loading the files into the ArrayAdapter using an
AsyncTask that fires up a 'Loading...' ProgressDialog onPreExecute(),
and closes it down onPostExecute().  In doInBackground(), I iterate
through the files returned from a listFiles() call, storing the file
names into the ArrayAdapter.

In terms of the AsyncTask, I've taken some direction here from Romain
Guy's Shelves application in terms of the AsyncTask properly pausing/
storing, etc when it gets interrupted, and killed on Application
termination.  Everything here works OK, except that the ArrayAdapter
can only tie in a single value (the filename in this case) to the
View, and I's like to tie in multiple values/views pairs (in my case,
filename, modified date).

I've seen this done in the Notepad sample application, but that uses
the SimpleCursorAdapter, but my understanding is that is exclusively
tied to Cursors, and thus the SQLite database, which I don't need.

So, here are my issues as I try to extend the very basic app:

1) How do I bind multiple values to multiple Views in the adapter.
ArrayAdapter can't do it, is there another more appropriate option, or
am I looking at creating my own custom adapter?  If so, any example
and/or suggestions on how to best proceed?

2) Am I going down the completely wrong path here with how I am tying
files into the List... is there some 'hybrid' way to tie files to a
Cursor such that I could use the SimpleCursorAdapter to handle all of
this?

3) As a follow-up to that, in terms of adding items, I have an
OptionsMenu that launches a Note Editing function (very similar to the
Notepad example).  I can create XML files via this method, but on
going back to the ListView, the new items are not in the List,
unsurprisingly.  Notepad does this via the ContentResolver.insert()
method, but with physical files scanned from the directory, I'm just
not sure how I should be proceeding to update the List... I'd rather
not have to re-scan every time a new note is added, but that may be my
only option, as far as I know.  Again, any help here is much
appreciated.  I see ArrayAdapter has insert/remove methods, but when
in the child Editing activity, I'm not sure how I can access these
(ContentResolver?).  Thanks for any clarification here.

3) In terms of the Uri I define for each item, I am generating it from
the absolute filepath, due to the fact that it may be possible in
future versions to move/store files on the SD card, and I'm trying to
maintain the Uniqueness of the Uri.  Anyone see any issues with this
solution?

A very broad question, I hope the basic gist is clear...  just trying
to determine the best way to star so that I can move forward in the
most efficient and correct way.

Thanks in advance,

Paul


--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to