Tuesday, April 2, 2013

CSVListExample Source code walk-through

Continuing with the recent trend. Here is another source code walk-through. This one is an example project that demonstrates how to create a Custom ArrayAdapter to load some data from a CSV file into a ListView



10 comments:

  1. Hi,

    I implemented part of your code in my App but I want to display 3 items from my csv file.

    You use this to show only one item I want to show 2 more Items. mView.setText(getItem(pos).getAname());


    Is there a way to show 3 items and that these can have their own placement in the row?

    Thank you very much in advance :)

    Regards,
    Nicola Lombardi

    ReplyDelete
  2. yes definitely. You would make a row.xml file and inflate that from your getView() method. Get references to all of your TextViews and set them to whatever fields you want from your CSV data. See this other example of mine: https://github.com/FoamyGuy/StackSites check out the row_site.xml inside layout\ and the getView() method inside of the Adapter. for an example that uses multiple Views instead of just 1. The data in this example comes from XML instead of CSV, but the way the getView() works is basically the same. Let me know if you are unable to get it worked out, if you can't I'll make a csv example that uses 3 TextViews later tonight and put it on github.

    ReplyDelete
  3. Hi,

    I just figured out how to do this.
    Thak you

    ReplyDelete
  4. Hi there,

    Man amazing tnx I completely understood you and it works just fine :). Once more thank you very much for your help.

    Regards,
    Nicola Lombardi

    ReplyDelete
  5. Hi,

    Me again question do you know how to implement a search button for the created csv list?
    Sorry to disturb you so much but I'm trying to implement this the whole day already.

    tnx in advance,

    ReplyDelete
  6. Hi,

    Sorry man but I can not figure it out, all the examples online are using a standard arraylist. Can you please help me :)
    Thank you very very much in advance.

    ReplyDelete
  7. post a link to one of the examples that you've found that uses an arraylist... It can probably be modified slightly to work with arrayadapter.

    ReplyDelete
  8. Thank you so much for your reply :), I'm going nuts here and since it is my internship project I really want to finish it.

    Yes I used your CSV tutorial and implemented it on my app.
    I'm using ActionBarSherlock with SherlockFragments.

    I have a fragment that contains buttons, by pressing one of these buttons another fragment is called. This fragment (departurepointFragment) is called to show the list of airports I have imported from the CSV file. DeparturepointFragment uses the CSVAdapter (the one on your tutorial). With setListAdapter(adapter); in the onActivityCreated it loads the list.

    There are 8000 airports in the list, so most likely the user will want to search to find and select the desired airport.
    This is why I implemented the searchView widget in the DeparturepointFragment so the user can search throughout the displayed list. But I can not figure out how to implement this. All search examples are with activities or with an arraylist in an activity. I tried everything but I'm really lost.

    You can see my code here:
    http://stackoverflow.com/questions/16606610/searchview-csv-arraylist

    Examples what I think are close to what I want to accomplish:
    http://stackoverflow.com/questions/13493457/separate-searchview-for-fragments

    http://www.survivingwithandroid.com/2012/10/android-listview-custom-filter-and.html


    I just want to search the list I created and than select a airport from the search results.

    Thank you in advance man, really appreciated, I want to help people just like you do but I'm still a nooby. Helping each other is the best way to survive in this constantly changing android world :).

    ReplyDelete
  9. Hi FoamyGuy,
    I found you on Stackoverflow. I was wondering if you wanted to do a small partnership to promote the upcoming Samsung Smart App Challenge. I can give you more details via email. If you are interested please email me back john@fllu.com

    ReplyDelete
  10. Good Day, I have got a working example of your CSV to Listview, but I am in urgent need on how I can use your example to filter by EditText, I cannot filter, I have been trying now for long. Could you please help me? - Thanks

    ReplyDelete