Saturday 15 January 2011

android - Adding TextView dynamically to an layout for a messaging app -



android - Adding TextView dynamically to an layout for a messaging app -

i trying build simple messaging app. have 1 edittext , 1 button @ bottom of screen. when enters text , click send button entered text should appear msg on top of (edittext , button). if user have sent lots of msgs unable fit fit in screen, scrollbar scrolling , viewing msgs should automatically appear.

i have made layout

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".mainactivity"> <button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/button_send" android:id="@+id/button" android:layout_alignparentbottom="true" android:layout_alignparentright="true" android:layout_alignparentend="true" android:textcolor="@android:color/black" android:onclick="sendmessage"/> <edittext android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/edittext" android:hint="@string/edit_message" android:layout_alignparentleft="true" android:layout_alignparentstart="true" android:layout_toleftof="@+id/button" android:layout_tostartof="@+id/button" android:layout_alignparentbottom="true"/> </relativelayout>

and java code fetch msg

public void sendmessage(view view) { edittext edittext = (edittext) findviewbyid(r.id.edittext); string message = edittext.gettext().tostring(); }

i need guide me how proceed after this.

i want msg appear above each time. help or suggestion great helpful me.

for simpler solution, might want seek using 1 textview. maintain adding new messages it. create own custom layout different combinations possible (e.g timestamps, emojis). custom layout draws different items on there.

android android-intent android-activity android-fragments

No comments:

Post a Comment