android - Displaying continuous chats from a user in a same bubble -


I am working on the chat app .. I have done so far. Chat BW 2

Now what I want is: >

Please I'm stuck and know how to work on this UI .. ie If a user views the view chat again, then if the user continues the message from a user, then show them in the same image in the second image. This chat thing is that all local, no service or The server is not used. I am giving my code.

MessageActivity.java

  The expansion of public class MessageActivity list is called {/ ** when the activity was created first Override public zeros at * Arreelist & lt; Message & Messages; AwesomeAdapter Adapter; Edit Text; @Create (Bundle Saved InstanceStat) {Super.New (Saved Instantstate); setContentView (R.layout.main ); Text = (editing text) this.findViewById (R.id.text); this.setTitle ("Harish"); Names = New Arrestist & lt; Message & gt; (); Adapter = new AwesomeAdapter (this, message); SetListAdapter (adapter); } Public Zero Send Message (View V) {String Newmessage = Text .gettext (). ToString () Trim (); // String msg = "\ nCheck"; If (newMessage.length ()> gt; {text.setText (""); // addNewMessage (new message (new message + message, true)); AddNewMessage (new message (new message, true)); }} Public Zero sendMessage2 (see V) {string newMessage = text.getText (). ToString () Trim (); If (newMessage.length ()> gt; {text.setText (""); AddNewMessage (new message (new message, incorrect)); }} Zero addNewMessage (Message Me) {messages.add (m); Adapter.notifyDataSetChanged (); GetListView () setSelection (messages.size () - 1). }  

}

AwesomeAdapter.java

  increases the AwesomeAdapter BaseAdapter public class {Private reference mContext; Private Arrestist & lt; Message & gt; MMessages; Public AwesomeAdapter (Reference Reference, ArrayList & lt; Message & Messages; Message) {Super; This.mContext = context; this. Message message =; } @ Override Public In Receipt () {Return MMSs. (); } @OverWide Public Object Attitudes (return status) {Return MMSsJ.Jet (status); } @ Override public view getView (view the status of the int, view the conversion, view group origin) {message message = (message) this.getItem (status); See holder holder; If (convertView == faucet) {holder = new ViewHolder (); Convertview = Layout Inflator. From (MCTXT). Inflight (R.Let.SMS_O, parent, falls); Holder Message = (TextView) ConvertViewFindVBIID (RED Message MessageText); ConvertView.setTag (holder); } And holder = (seeholder) ConvertView .getTag (); Holder.message.setText (message.getMessage ()); Layout: LP = (LayerPrump) Holder Message.getLayoutParams (); If (message.isMine ()) {holder.message.setBackgroundResource (R.drawable.me); Lp.setMargins (15, 10, 0, 10); } And {holder Message.setbackgrid resource (R.drawable.you); LP. Set Margin (0, 10, 15, 10); } Holder Message.setLayoutParams (LP); Return Convertview; } Private Static Class Viewer {TextView Message; } @ Override Public Long ITMID (Int Position) {// Tudo Auto-Generated Method Stub Return 0; }  

}

message. Java

  public class messages {string message; Bullion is Mean; Public message (string message, boolean is Pisces) {super (); This.message = Message; This.isMine = Money; } / ** * Constructor message object to create a position * Consider that the parameter is swapped from the default message constructor, is not a good approach, but it has to go with I * / public message (boolean status, string Message) {super (); This.message = Message; This.isMine = false; } Public string getMessage () {return message; } Public boolean is Mean () {return hamain; }  

}

"itemprop =" text ">

after the new message is being received, that Attached message & gt; ArrayList & lt messages on the previous message (i.e. get the previous message from ArrayList and attach this new message with a line break (link \ n ) and it should be working) And call adapter.notifyDataSetChanged ();


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -