Activité envoi de messages instantanés
authorPhilippe Lago <lago_p@epitech.net>
Mon, 23 Mar 2009 15:23:36 +0100
changeset 26 45de80223558
parent 25 1e044613960c
child 27 cd37b4d817ec
Activité envoi de messages instantanés
res/layout/messagelist.xml
res/layout/sendim.xml
src/com/beem/project/beem/ui/SendIM.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/res/layout/messagelist.xml	Mon Mar 23 15:23:36 2009 +0100
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<TextView xmlns:android="http://schemas.android.com/apk/res/android" id="text1"
+          android:textStyle="bold"
+          android:singleLine="false"
+          android:layout_width="fill_parent"
+          android:layout_height="wrap_content"/>
\ No newline at end of file
--- a/res/layout/sendim.xml	Sat Mar 21 00:48:28 2009 +0100
+++ b/res/layout/sendim.xml	Mon Mar 23 15:23:36 2009 +0100
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
               android:orientation="vertical"
               android:layout_width="fill_parent"
--- a/src/com/beem/project/beem/ui/SendIM.java	Sat Mar 21 00:48:28 2009 +0100
+++ b/src/com/beem/project/beem/ui/SendIM.java	Mon Mar 23 15:23:36 2009 +0100
@@ -7,13 +7,16 @@
 import android.app.Activity;
 import android.os.Bundle;
 import android.view.View;
+import android.widget.ArrayAdapter;
 import android.widget.Button;
 import android.widget.EditText;
+import android.widget.ListView;
 
 import com.beem.project.beem.R;
 
 public class SendIM extends Activity {
 	private EditText		mToSend;
+	private ListView		mList;
 	private ArrayList<String>	mMessages = new ArrayList<String>();
 	
 	@Override
@@ -21,6 +24,7 @@
         super.onCreate(saveBundle);
         setContentView(R.layout.sendim);
         mToSend = (EditText) findViewById(R.id.sendText);
+        mList = (ListView) findViewById(R.id.listMessages);
         
         Button send = (Button) this.findViewById(R.id.send);
         send.setOnClickListener(new View.OnClickListener() {
@@ -31,7 +35,14 @@
                  * */
                 Message msg = new Message("barbu", Message.Type.chat);
                 msg.setBody(text);
+                mMessages.add(text);
+                setListAdapter();
             }
         });
 	}
+	
+	private void setListAdapter() {
+	    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.messagelist, mMessages);
+	    mList.setAdapter(adapter);
+	}
 }