text display problem in ListView

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

text display problem in ListView

Postby lakshmanraob » Tue Nov 03, 2009 6:19 pm

hi all,
I am new to android. I tried to implement the listview on my own, learned few basics from this forum. I stuck with the following problem need some help from you guys.

I am unable to display the text (as i want), it is display in the following way com.xx.className@43789fa8(some scrap)
I am working on a share application need to display the share name, but unable to display that

I am giving the code snippet also.. please help me



listShare.add(new Shares("a", 10.1, 50,false));
listShare.add(new Shares("b", 6.1, 50,true));
listShare.add(new Shares("c", 18.6, 50,false));
listShare.add(new Shares("d", 17.1, 50,true));
listShare.add(new Shares("e", 10, 50,true));
listShare.add(new Shares("f", 0.56, 50,false));


this.listshView = (ListView)findViewById(R.id.list_shares);
initListView();


Thanks for the help

lakshman
lakshmanraob
Junior Developer
Junior Developer
 
Posts: 18
Joined: Mon Mar 23, 2009 8:11 pm

Top

Postby lakshmanraob » Wed Nov 04, 2009 5:07 pm

List view display problem, where the string is not displayed properly. somebody please help me out.
lakshmanraob
Junior Developer
Junior Developer
 
Posts: 18
Joined: Mon Mar 23, 2009 8:11 pm

Postby rmanromga » Thu Nov 05, 2009 9:21 pm

Your post does not have enough details for someone to try to help you... what does the function

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. listShare.add(new Shares("a", 10.1, 50,false));
  2.  
  3.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4

do? Is your problem that the strings to be displayed on the textviews of the list have special characters in them? you will have to present your problem a little better...
rmanromga
Developer
Developer
 
Posts: 43
Joined: Thu Dec 20, 2007 6:21 am
Location: Baltimore, MD USA

Postby lakshmanraob » Fri Nov 06, 2009 6:07 am

HI,
Thanks for the reply. IN my code i had the problem in displaying the Text in the List View. The Share class is a Class which holds the details about the particular stock.
I want to display the n - number of stocks in the listView. so I am just adding the shares object to the list view. when i am displaying, the object is displayed say in (special characters). as like if you try to display the object in java.
I want to display the share in the following way
--------------------------------------------------------
shareName (ShareValue)
marketValue (Investement Value)
(up/down) (up/down)
--------------------------------------------------------
shareName (ShareValue)
marketValue (Investement Value)
(up/down) (up/down)
--------------------------------------------------------

So every share object in the List View was supposed to display in this way. In the process of achieving that i stuck in the object display.
Please help me out in display the share object properly.

Is there any way we can restrict the number of List view Items display. say now the device is display 10 at a time. I want to display only 5 at a time when the user scrolls the remaining objects need to show.

Please help me out
Thanks for your time
lakshman
lakshmanraob
Junior Developer
Junior Developer
 
Posts: 18
Joined: Mon Mar 23, 2009 8:11 pm

Postby qlimax » Sat Nov 07, 2009 6:02 pm

Hi,

you have a toString method in your Shares class

for example

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. class Shares{
  2.  
  3. String name;
  4.  
  5. String marketValue;
  6.  
  7. boolean upDown;
  8.  
  9.  
  10.  
  11. ....
  12.  
  13.  
  14.  
  15.  
  16.  
  17. public String toString(){
  18.  
  19.  
  20.  
  21. return "Market Name: "+name+"\nMarket Value: "+value+"\nUp/Down: "+check;  //the string representation of a share object
  22.  
  23. }
  24.  
  25.  
  26.  
  27. }
Parsed in 0.031 seconds, using GeSHi 1.0.8.4



then you will able to properly add Shares objects to the listview .

bye :arrow:
¯`·.¸¸.><((((º>¯`·.¸¸. ><((((º>
User avatar
qlimax
Master Developer
Master Developer
 
Posts: 271
Joined: Mon Aug 31, 2009 10:54 am
Location: Swiss

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 6 guests