0

I am working on a chat application with smileys. I have a image button that shows a pop up of smileys in grid view when clicked. I can select any smiley in that and it will get displayed in Edit Text.

My problem is : Now i have smiley image and text in my edittext. when i click on send i need to display this message with smiley in listview. Is it possible to display images with text in listview where i get mesages from webservice.

List view is used here as a place to display messages from web service. How can i work further in this.

Please guide me in this issue.

Regards, Raghav Rajagopalan

  • yes it is possible of course. If you are using some complex way to get the messages from the webservice into the adapter.. You must integrate this with sending these to the adapter – Sherif elKhatib Sep 24 '11 at 06:06
  • Is it possible to send images to webservice and fetch them back in my listview. I am using .Net web service. I return XML from web service as my response. – Raghav Rajagopalan Sep 24 '11 at 06:20
  • 1
    don't do that ... put your smileys in `drawable` or download them only once. Use your own tags for smileys.. For example when string :) occurs put a smiley – Sherif elKhatib Sep 24 '11 at 06:27
  • Yes you are correct. I created a Db and added 4 fields to it. 1.ID , 2. Position, 3. Special Character 4. URL. So i was able to display the corresponding specialcharcter when clicked. when i submit how can i convert that specialcharcter into smiley image. I tried to use functions like "Contains()" and "Replace". But nothing worked when i submited the message to listview. I get the same specialcharcter and text. I don get the image instead of specialcharcter. please guide me. – Raghav Rajagopalan Sep 24 '11 at 06:39

1 Answers1

1

Is it possible to display images with text in listview where i get mesages from webservice.

  • Yes it is possible of course. If you are using some complex way to get the messages from the webservice into the adapter, you must integrate this with sending these to the adapter.

Is it possible to send images to webservice and fetch them back in my listview. I am using .Net web service. I return XML from web service as my response.

  • Don not do that. Put your smileys in drawable or download them only once. Use your own tags inside text for smileys. For example when string :) occurs put a smiley.

I created a Db and added 4 fields to it: ID , Position, Special Character, URL. So i was able to display the corresponding specialcharcter when clicked. When i submit how can i convert that specialcharcter into smiley image. I tried to use functions like "Contains()" and "Replace". But nothing worked when i submited the message to listview. I get the same specialcharcter and text. I don get the image instead of specialcharcter. Please guide me

  • I suppose you are inserting the message inside a textView. You can use to replace the occurances of the special character with "<img src=\"the source\" />"
  • Use this to get the image shown setText(Html.fromHtml("hi how are you <img src=\"yourimage.png\" />"));
  • To replace :) with <img src=\"yourimage.png\" />.. use yourString.replaceAll(":)","<img src=\"yourimage.png\" />");
Sherif elKhatib
  • 45,786
  • 16
  • 89
  • 106
  • as i informed you earlier i ve tried with replacing special character with replace and contains. can you pls tell me how to use these functions. I think i might have used these functions in correctly. Can you guide me friend. – Raghav Rajagopalan Sep 24 '11 at 06:52
  • tell me first.. Were you able to replace the special character? or no effect at all? – Sherif elKhatib Sep 24 '11 at 06:54
  • 1
    no effect at all. i get the same the hi :) in my message list. what i was looking for is hi image. – Raghav Rajagopalan Sep 24 '11 at 07:17
  • Check the answer: I updated it. use this to get the image shown `setText(Html.fromHtml("hi how are you "));` I am sorry for late reply: to replace `:)` with ``.. use `yourString.replaceAll(":)","");` – Sherif elKhatib Sep 24 '11 at 12:50