#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2010
    Posts
    67
    Rep Power
    0

    Smile Android listview problem


    Guys i am creating an app that will have almost 500+ list items... and on each item click i want to display info of that item..

    eg: if i have list of 500 cars ... if i select audi i will get a textview or something of audi.......ie information about it ..


    but the main problem is for 500 list view items i cannot make other 500 activities to display text of related listview..

    what will be the best way?? i will display only static text .. will webview be better or textview or any better options?
    I am new to android .... sorry !!!
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    17
    Rep Power
    0
    So this is a case where you want to use the extras. I'm not totally positive what you're trying to do or what data you have but here is a thought on a way to accomplish what you're looking for.

    So to create the list view, you have to use some sort of Adapter. The most basic is ArrayAdapter<E>. So if you have an object Car, you can create an ArrayList of cars and then your adapter will be ArrayAdapter<Car>.

    In order to display each car in the list, you will either have to create a custom adapter which you can look up in various tutorials OR you can just grab the names of the cars

    so for example you can pass an ArrayList<String> to the adapter for the data and use grab each car name by iterating through your car array and storing car.getName()

    Now that you have this in your list, each item has a name associated with it. When a user clicks an item, you can get the string associated with that cell using the adapter.getItemSelected(position) to get your string.

    Then you can take the string and put it in the intent extras

    intent.putExtra("CAR TYPE",selectedItem)

    then on the new activity, you can get the string by using

    getIntent().getExtras.getString("CAR TYPE") and there you have the car that was selected. From there you can do a reverse search based on the car you have and get all it's info to populate your ONE activity that you made.

    Hope this helps


    Originally Posted by swapy
    Guys i am creating an app that will have almost 500+ list items... and on each item click i want to display info of that item..

    eg: if i have list of 500 cars ... if i select audi i will get a textview or something of audi.......ie information about it ..


    but the main problem is for 500 list view items i cannot make other 500 activities to display text of related listview..

    what will be the best way?? i will display only static text .. will webview be better or textview or any better options?
    I am new to android .... sorry !!!

IMN logo majestic logo threadwatch logo seochat tools logo