views:

33

answers:

1

I cant be able to show my data into a listview using this code which Ive found on a particular website. I am able to show all the images in listview but the data are not there! Someone please help!

db = new DBAdapter(this); 

            toptext = (TextView) findViewById (R.id.toptext); 
            bottomtext = (TextView) findViewById (R.id.bottomtext); 

            ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();

            HashMap<String, String> item;
            for (int i = 0; i < 31; i++) {

                    item = new HashMap<String, String>();
                    item.put("Date:", "Saved Date" );
                    item.put("Title:", "Saved Title");
                    list.add(item);
            }

            SimpleAdapter notes = new SimpleAdapter(this, list, R.layout.view_list,
                                    new String[] { "date", "title" }, 
                                    new int[] {R.id.toptext, R.id.bottomtext });
            setListAdapter(notes);

        } catch(Throwable e){ 

        Log.e("DBAdapter",e.toString()); 

        } 

What should I change or do? For clearer explanation you can mail me at [email protected] :)

A: 

that code looks like an example that assumes that you will fill in the blanks. It doesn't do anything you want. There are literally 50 good tutorials about to to work with adapters and listviews available. Google is your friend: http://www.google.com/search?hl=&amp;q=android+listview+tutorial

EDIT: I highly recommend that you go back to the beginning... you will not be able to create a decent application if you don't know the basics. There are lots of java tutorials for beginners on the web and more than enough android development tutorials to get you started along with literally thousands of open source android apps to learn from. If you have $40 to spare I highly recommend that you buy a subscription to CommonsWare: http://commonsware.com/ because it's the same author as Beginning Android 2 (same book is given in the subscription under a different title) and you get 3 great books with all of the source code. The author posts here on StackOverflow daily and his books and advice have led me from beginner to app author (along with others help).

androidworkz
Ive tried many examples, too many that I am so lost.
UserA
see edit above. I didn't have enough space here in the comments to post it.
androidworkz