title: Layout similar to whatsapp
body: <p><strong>I am designing layout same as Whatsapp application (where chat is displayed) interface...there is some error i  don't know what happen ...</strong></p>
  
  <pre><code> package com.example.coder;
  
      import java.util.ArrayList;
      import java.util.List;
  
      import com.example.coder.Custom.Row;
      import com.example.coder.CustomArrayAdapter.ViewHolder;
      import com.example.coder.Whats.MessageData;
  
      import android.app.Activity;
      import android.app.ListActivity;
      import android.content.Context;
      import android.os.Bundle;
      import android.view.LayoutInflater;
      import android.view.View;
      import android.view.View.OnClickListener;
      import android.view.ViewGroup;
      import android.widget.ArrayAdapter;
      import android.widget.Button;
      import android.widget.EditText;
      import android.widget.ImageView;
      import android.widget.ListView;
      import android.widget.TextView;
  
      public class Whats extends Activity {
          MessageAdapter&lt;MessageData&gt; adapter;
          EditText message;
          List&lt;MessageData&gt; msgs;
          Button b;
  
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.whats_helper);
  
               message = (EditText) findViewById(R.id.enter_message);
  
              ListView lv = (ListView) findViewById(R.id.list);
              msgs =  new ArrayList&lt;MessageData&gt;();
  
              b=(Button)findViewById(R.id.send_button);
  
               adapter=new MessageAdapter&lt;MessageData&gt;(this,R.layout.whats,msgs);
               lv.setAdapter(adapter);
          }
  
  
          public void sendMessage() {    
  
              String mText = message.getText().toString();
              msgs.add(new MessageData(mText));
              adapter.notifyDataSetChanged();
              message.setText("");
          }
          public class MessageData {
              private String message;
  
              public MessageData(String message) {
                  this.message = message;
              }
              public void setMessage(String message) {
                  this.message = message;
              }
              public String getMessage() {
                  return message;
              }
          }
          public class MessageAdapter&lt;T&gt; extends ArrayAdapter&lt;MessageData&gt; {
  
  
              Context context;
          public MessageAdapter(Context context,int resource, List&lt;MessageData&gt; objs) {
              super(context,resource,objs);
             this.context=context;
  
          }
          @Override
          public View getView(int position, View convertView, ViewGroup parent) {
  
  
  
              MessageView msgView = null;
  
              LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
              if(convertView == null)
              {
                  // Get a new instance of the row layout view
  
                  convertView = mInflater.inflate(R.layout.whats, null);
  
                  // Hold the view objects in an object,
                  // so they don't need to be re-fetched
                  msgView = new MessageView();
                  msgView.msg = (TextView) convertView.findViewById(R.id.message_text);
  
                  // Cache the view objects in the tag,
                  // so they can be re-accessed later
                  convertView.setTag(msgView);
              } else {
                  msgView = (MessageView) convertView.getTag();
              }
  
              // Transfer the stock data from the data object
              // to the view objects
              MessageData currentMsg =  getItem(position);
              msgView.msg.setText(currentMsg.getMessage());
  
              return convertView;
          }
  
            class MessageView {
               TextView msg;
          }
      }
  
      }
  </code></pre>
  
  <p><strong>Layout for Whats Activity</strong>  This is the layout used by Whats activity...</p>
  
  <pre><code>  &lt;LinearLayout 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"
          android:orientation="vertical"&gt;
  
  
          &lt;!--&lt;FrameLayout--&gt;
              &lt;!--android:background="@color/header_color"--&gt;
              &lt;!--android:layout_width="match_parent"--&gt;
              &lt;!--android:layout_height="0dp"--&gt;
              &lt;!--android:layout_weight="1"&gt;--&gt;
  
          &lt;!--&lt;/FrameLayout&gt;--&gt;
  
          &lt;LinearLayout
              android:layout_width="match_parent"
              android:orientation="vertical"
              android:layout_height="0dp"
              android:layout_weight="10"&gt;
  
              &lt;FrameLayout
                  android:layout_height="0dp"
                  android:layout_width="match_parent"
                  android:layout_weight="11"&gt;
  
                  &lt;ListView
                      android:id="@+android:id/list"
  
                      android:drawSelectorOnTop="false"
                      android:layout_height="match_parent"
                      android:layout_width="match_parent"
                      android:footerDividersEnabled="true"&gt;
  
  
                  &lt;/ListView&gt;
  
              &lt;/FrameLayout&gt;
  
  
              &lt;FrameLayout
                  android:layout_height="0dp"
                  android:layout_width="match_parent"
                  android:layout_weight="1"&gt;
  
                  &lt;LinearLayout
                      android:layout_height="match_parent"
                      android:layout_width="match_parent"
  
                      android:id="@+id/linearLayout"&gt;
  
                      &lt;EditText
                          android:id="@+id/enter_message"
                          android:layout_width="0dp"
                          android:layout_height="match_parent"
                          android:layout_weight="1"
                          android:hint="edit_text" /&gt;
  
                      &lt;Button
                          android:id="@+id/send_button"
                          android:layout_width="45dp"
                          android:layout_height="30dp"
  
                          android:onClick="sendMessage"/&gt;
  
                  &lt;/LinearLayout&gt;
  
              &lt;/FrameLayout&gt;
  
          &lt;/LinearLayout&gt;
  
      &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>Layout For Individual Text</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:gravity="fill_horizontal"
      android:layout_height="wrap_content"&gt;
  
      &lt;RelativeLayout
          android:layout_height="wrap_content"
          android:layout_width="match_parent"&gt;
  
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:gravity="right"
              android:layout_marginTop="@dimen/activity_horizontal_margin"
  
              android:id="@+id/message_text" /&gt;
  
      &lt;/RelativeLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>*<strong>ERROR LOG *</strong></p>
  
  <pre><code>02-05 21:41:58.560: E/AndroidRuntime(2346): in writeCrashedAppName, pkgName :com.example.coder
  02-05 21:41:58.560: D/AndroidRuntime(2346): file written successfully with content: com.example.coder StringBuffer : ;com.example.coder
  02-05 21:41:58.570: I/Process(2346): Sending signal. PID: 2346 SIG: 9
  02-05 21:41:58.570: E/AndroidRuntime(2346): FATAL EXCEPTION: main
  02-05 21:41:58.570: E/AndroidRuntime(2346): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.coder/com.example.coder.Whats}: java.lang.NullPointerException
  02-05 21:41:58.570: E/AndroidRuntime(2346):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
  02-05 21:41:58.570: E/AndroidRuntime(2346):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
  02-05 21:41:58.570: E/AndroidRuntime(2346):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
  02-05 21:41:58.570: E/AndroidRuntime(2346):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
  02-05 21:41:58.570: E/AndroidRuntime(2346):     at android.os.Handler.dispatchMessage(Handler.java:99)
  02-05 21:41:58.570: E/AndroidRuntime(2346):     at android.os.Looper.loop(Looper.java:130)
  02-05 21:41:58.570: E/AndroidRuntime(2346):     at android.app.ActivityThread.main(ActivityThread.java:3683)
  02-05 21:41:58.570: E/AndroidRuntime(2346):     at java.lang.reflect.Method.invokeNative(Native Method)
  02-05 21:41:58.570: E/AndroidRuntime(2346):     at java.lang.reflect.Method.invoke(Method.java:507)
  02-05 21:41:58.570: E/AndroidRuntime(2346):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880)
  02-05 21:41:58.570: E/AndroidRuntime(2346):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:638)
  02-05 21:41:58.570: E/AndroidRuntime(2346):     at dalvik.system.NativeStart.main(Native Method)
  02-05 21:41:58.570: E/AndroidRuntime(2346): Caused by: java.lang.NullPointerException
  02-05 21:41:58.570: E/AndroidRuntime(2346):     at com.example.coder.Whats.onCreate(Whats.java:44)
  02-05 21:41:58.570: E/AndroidRuntime(2346):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
  02-05 21:41:58.570: E/AndroidRuntime(2346):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
  </code></pre>