Android Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsMobile ProgrammingAndroid Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 4th, 2012, 01:34 AM
swapy swapy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2010
Posts: 66 swapy Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 14 h 4 m
Reputation 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 !!!

Reply With Quote
  #2  
Old November 13th, 2012, 02:42 PM
bransby bransby is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2012
Posts: 17 bransby User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 14 m 51 sec
Reputation 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


Quote:
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 !!!

Reply With Quote
Reply

Viewing: Dev Shed ForumsMobile ProgrammingAndroid Development > Android listview problem

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap