I am trying to make a chat application in android using xmpp. I am able to do chat with simple array adapter but when i am trying to set custom adapter on the listview then i am getting error in my code. please help me. where i am going wrong. 

My custom Adapter code:

```
public class ChatArrayAdapter extends ArrayAdapter
{
    private TextView chatText;

    private LinearLayout singleMessageContainer;

    private Activity activity;

    public ChatArrayAdapter(Context context, int textViewResourceId, List chatList) {
        super(context, textViewResourceId, chatList);
    }

    public void add(ChatMessage object) {
        chatMessageList.add(object);
        super.add(object);
    }

    public ChatArrayAdapter(Context context, int textViewResourceId) {
        super(context, textViewResourceId);
    }

    public int getCount() {
        return chatMessageList.size();
    }

    public ChatMessage getItem(int index) {
        return (ChatMessage) chatMessageList.get(index);
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        View row = convertView;
        if (row == null) {
            LayoutInflater inflater = (LayoutInflater) this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            row = inflater.inflate(R.layout.chat_singlemessage, parent, false);
        }
        singleMessageContainer = (LinearLayout) row.findViewById(R.id.singleMessageContainer);
        ChatMessage chatMessageObj = getItem(position);
        chatText = (TextView) row.findViewById(R.id.singleMessage);
        chatText.setText(chatMessageObj.message);
        chatText.setBackgroundResource(chatMessageObj.left ? R.drawable.bubbleaaa : R.drawable.bubblebbb);
        singleMessageContainer.setGravity(chatMessageObj.left ? Gravity.LEFT : Gravity.RIGHT);
        return row;
    }

    public Bitmap decodeToBitmap(byte[] decodedByte) {
        return BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length);
    }

}

```

ChatMessage class:

```
public class ChatMessage
{
    public boolean left;
public String message;

public ChatMessage(boolean left, String message) {
    super();
    this.left = left;
    this.message = message;
}
}

```

Errors:

```
01-30 14:39:05.663  10813-10813/com.example.welcome.kids_chat E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.welcome.kids_chat, PID: 10813
java.lang.ClassCastException: java.lang.String cannot be cast to com.example.welcome.kids_chat.ChatMessage
        at com.example.welcome.kids_chat.Chat_Screen$ChatArrayAdapter.getItem(Chat_Screen.java:307)
        at com.example.welcome.kids_chat.Chat_Screen$ChatArrayAdapter.getView(Chat_Screen.java:317)
        at android.widget.AbsListView.obtainView(AbsListView.java:2301)
        at android.widget.ListView.measureHeightOfChildren(ListView.java:1274)
        at android.widget.ListView.onMeasure(ListView.java:1186)
        at android.view.View.measure(View.java:16677)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5286)
        at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
        at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
        at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
        at android.view.View.measure(View.java:16677)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5286)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
        at android.view.View.measure(View.java:16677)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5286)
        at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
        at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
        at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
        at android.view.View.measure(View.java:16677)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5286)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
        at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2421)
        at android.view.View.measure(View.java:16677)
        at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1927)
        at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1119)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1301)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1006)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5652)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
        at android.view.Choreographer.doCallbacks(Choreographer.java:574)
        at android.view.Choreographer.doFrame(Choreographer.java:544)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
        at android.os.Handler.handleCallback(Handler.java:733)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:5426)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
        at dalvik.system.NativeStart.main(Native Method)

```