Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ListView Problem

 
Hardik Trivedi
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am making an application in which user can configure their mail accounts.
I am able to retrieve mails from mail server.But the problem is with view.I am using SimpleAdapter to display the content.It works fine when there is only text content.

What I want to do is when mail has an attachment, I want to display an icon instead of text.Now this creates problem because I have used Arraylist to pass the argument in SimpleAdapter.

Is there any one who has solution of this.

If question is not clear to anyone they can ask for more.

Please I am stuck up here since 3 days.

Thank you
 
James Elsey
Ranch Hand
Posts: 228
Android IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you post up some of your code so we can see what you are doing?
 
Hardik Trivedi
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James Elsey wrote:can you post up some of your code so we can see what you are doing?


I have not started the code because I have no idea from where I should start
I know how to do mapping between data and fields (i.e from and to) in SimpleAdapter but what about images.

OK,you must have seen Email application given with android SDK preinstalled.When you view your inbox your mails are listed.I want to prepare same kind of view.

But for your reference I am giving image.


I want to prepare above kind of view.But with the SimpleAdapter
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The SimpleAdapter javadocs talk of either a boolean, a string or an image, not of combinations thereof (which is probably what makes it "Simple"). You'll probably have to use an ArrayAdapter, or subclass it.
 
Hardik Trivedi
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, first of all thank you for the reply.

I refer some example of ArrayAdapter but still can not make it out.
Can you share some demo code?
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you have so far? What does your layout look like, particularly its XML definition?
 
Hardik Trivedi
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is how my xml looks like.


It is not similar to above given image.I have removed some content.I will add them later.The ImageView tag I have taken to display attachment icon.
 
Piyush Patel
Ranch Hand
Posts: 127
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you looked at API demo supplied with Android SDK ? please go through API Demos and there are 6-7 examples of ListActivities.

There is one example in API Demo for list activity that will solve you problems, it shows how to create customized Adapter.

hope this helps.. write back to forum if problem remains..

Regards,
Piyush

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic