0

I'm developing a simple XMPP-based chat app and now considering the ways to create a conversation layout. I plan to add a LinearLayout for each message containing the .9.png background, the actual text and the timestamp.

Question 1: what would fit better for the parent layout to which the message layouts will be added: a Relative- / LinearLayout inside a ScrollView or a ListView?

Question 2: what is the most simple way to save those message layouts so the messages stay when the user leaves the activity?

Peter O.
  • 32,158
  • 14
  • 82
  • 96
Droidman
  • 11,485
  • 17
  • 93
  • 141

1 Answers1

1

Question 1: what would fit better for the parent layout to which the message layouts will be added: a Relative- / LinearLayout inside a ScrollView or a ListView?

I'd go with ListView that way you'll have an Adapter and an easy access to each row, listeners, etc.

Question 2: what is the most simple way to save those message layouts so the messages stay when the user leaves the activity?

If its gonna be large data the best way is using SQLite DB. If it's not gonna be that big OR if you're looking for a simple solution - just save the ArrayList that represents the chat to file. Many examples are out there for saving Java objects to file and then loading it.

Peter O.
  • 32,158
  • 14
  • 82
  • 96
Givi
  • 3,283
  • 4
  • 20
  • 23
  • thanks. But is it possible to insert a layout into a ListView row? – Droidman Jan 09 '13 at 08:50
  • Sure. You can build and XML layout that will be the layout for each row. And you'll have to implement a custom adapter. Have a look at this: http://www.ezzylearning.com/tutorial.aspx?tid=1763429 – Givi Jan 09 '13 at 08:54