Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4605058
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:22:50+00:00 2026-05-22T00:22:50+00:00

I try all this day to resolve this error. I don’t understand why my

  • 0

I try all this day to resolve this error. I don’t understand why my logcat prints:

05-06 21:45:59.559:
ERROR/ConversationList(9023): We have
chats... 05-06 21:45:59.609:
ERROR/ConversationList(9023):
UpdateList end... 05-06 21:45:59.839:
ERROR/ArrayAdapter(9023): You must
supply a resource ID for a TextView
05-06 21:45:59.839:
DEBUG/AndroidRuntime(9023): Shutting
down VM 05-06 21:45:59.839:
WARN/dalvikvm(9023): threadid=3:
thread exiting with uncaught exception
(group=0x4000fe70) 05-06 21:45:59.839:
ERROR/AndroidRuntime(9023): Uncaught
handler: thread main exiting due to
uncaught exception 05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):
java.lang.IllegalStateException:
ArrayAdapter requires the resource ID
to be a TextView 05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     at
android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:347)
05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     at
android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     at
android.widget.AbsListView.obtainView(AbsListView.java:1269)
05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     at
android.widget.ListView.makeAndAddView(ListView.java:1623)
05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     at
android.widget.ListView.fillDown(ListView.java:607)
05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     at
android.widget.ListView.fillFromTop(ListView.java:664)
05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     at
android.widget.ListView.layoutChildren(ListView.java:1481)
05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     at
android.widget.AbsListView.onLayout(AbsListView.java:1113)
05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     at
android.view.View.layout(View.java:6133)
05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     at
android.widget.LinearLayout.setChildFrame(LinearLayout.java:1119)
05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     at
android.widget.LinearLayout.layoutVertical(LinearLayout.java:998)
05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     at
android.widget.LinearLayout.onLayout(LinearLayout.java:918)
05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     at
android.view.View.layout(View.java:6133)
05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     at
android.widget.FrameLayout.onLayout(FrameLayout.java:333)
05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     at
android.view.View.layout(View.java:6133)
05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     at
android.widget.LinearLayout.setChildFrame(LinearLayout.java:1119)
05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     at
android.widget.LinearLayout.layoutVertical(LinearLayout.java:998)
05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     at
android.widget.LinearLayout.onLayout(LinearLayout.java:918)
05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     at
android.view.View.layout(View.java:6133)
05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     at
android.widget.FrameLayout.onLayout(FrameLayout.java:333)
05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     at
android.view.View.layout(View.java:6133)
05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     at
android.view.ViewRoot.performTraversals(ViewRoot.java:929)
05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     at
android.view.ViewRoot.handleMessage(ViewRoot.java:1482)
05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     at
android.os.Handler.dispatchMessage(Handler.java:99)
05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     at
android.os.Looper.loop(Looper.java:123)
05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     at
android.app.ActivityThread.main(ActivityThread.java:3948)
05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     at
java.lang.reflect.Method.invokeNative(Native
Method) 05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     at
java.lang.reflect.Method.invoke(Method.java:521)
05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     at
dalvik.system.NativeStart.main(Native
Method) 05-06 21:45:59.879:
ERROR/AndroidRuntime(9023): Caused by:
java.lang.ClassCastException:
android.widget.LinearLayout 05-06
21:45:59.879:
ERROR/AndroidRuntime(9023):     at
android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:340)
05-06 21:45:59.879:
ERROR/AndroidRuntime(9023):     ... 30
more

My Java file:

package fshizzle.com;

import java.util.ArrayList;

import android.app.ListActivity;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.util.Log;
import android.view.ContextMenu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
import cz.jabbim.android.data.JabberoidDbConnector;
import fshizzle.com.R;

public class ConversationList extends ListActivity {

//  private static final String TAG = "ConversationList.class";
    private static final int RESULT_CHAT = 4004;
    private static final int RESULT_DIRECTCHAT = 4005;

    private static final String TAG = "ConversationList";

    private ArrayList<String> chatList = new ArrayList<String>();

    private TextView tv;

    private String lastJid;
    BroadcastReceiver csr;
    IntentFilter f;

    boolean show = true;

    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);

        setContentView(R.layout.conversationlist);

        tv = (TextView)findViewById(R.id.contactList_NoConversation);

        csr =  new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                getChats();
                updateList(false);
            }
        };
        f = new IntentFilter();
        f.addAction("cz.jabbim.android.androidim.NEW_MESSAGE");

        registerForContextMenu(getListView());

    }

    @Override
    public void onStart() {
        super.onStart();
        getChats();
        updateList(show);
        show = true;
        if(getIntent().getBooleanExtra("startChat", false)) {
            startChat(getIntent().getStringExtra("jid"));
            show = false;
        }

    }

    @Override
    public void onResume() {
        super.onResume();
        cancelNotification();

        registerReceiver(csr, f);
    }

    @Override
    public void onPause() {
        super.onPause();
        unregisterReceiver(csr);

    }

    @Override
    public void onStop() {
        super.onStop();

    }

    @Override
    protected void onListItemClick(ListView lv, View v, int pos, long id) {
        super.onListItemClick(lv, v, pos, id);
        startChat(pos);     
    }

    @Override
    public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
        new MenuInflater(getApplication()).inflate(R.menu.conversationlist_context, menu);
        AdapterContextMenuInfo acmi = (AdapterContextMenuInfo)menuInfo;
        menu.setHeaderTitle("Chat with " + getJid(acmi.position));

        super.onCreateContextMenu(menu, v, menuInfo);
    }

    @Override
    public boolean onContextItemSelected(MenuItem item) {
        AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) item.getMenuInfo();
        switch(item.getItemId()) {
        case R.id.menuEnter:
            startChat(acmi.position);
            return true;
        case R.id.menuCloseChat:
            closeChat(acmi.position);
            return true;
        }


        return super.onContextItemSelected(item);
    }

    private int getChats() {
        final String[] returnColumns = {
                Constants.TABLE_CONVERSATION_FIELD_ID,
                Constants.TABLE_CONVERSATION_FIELD_CHAT,
                "MIN("+(Constants.TABLE_CONVERSATION_FIELD_DATE)+") as 'firstReceived'",
               };

        SQLiteDatabase db = new JabberoidDbConnector(this).getWritableDatabase();

        Cursor result = db.query(Constants.TABLE_CONVERSATION, 
                returnColumns, 
                null, //Constants.TABLE_CONVERSATION_FIELD_FROM + "!= 'me'", 
                null, 
                Constants.TABLE_CONVERSATION_FIELD_CHAT, 
                null, 
                "firstReceived ASC" );

        int count = result.getCount();

        chatList.clear();
        result.moveToFirst();
        while(!result.isAfterLast()) {
            chatList.add(result.getString(result.getColumnIndex(Constants.TABLE_CONVERSATION_FIELD_CHAT)));
            //chatList.add("rafa@localhost.localdomain");
            result.moveToNext();
        }

        result.close();
        result = null;
        db.close();

        return count;
    }



        private void updateList(boolean startChat) {
        if(chatList.size() > 0) {

            if(chatList.size()==1 && startChat) {
                startChat(0);
            }
            Log.e(TAG, "We have chats...");
            tv.setVisibility(View.GONE);
            getListView().setVisibility(View.VISIBLE);





            ListAdapter adapter = new ArrayAdapter<String>(
                    this,
                    R.layout.conversation_item,
                    chatList
                );
            getListView().setAdapter(adapter);

            //startChat("rafa@localhost.localdomain");

        //  startChat(getIntent().getStringExtra("fromUser"));

        } else {
            Log.e(TAG, "We don't have chats...");
            getListView().setVisibility(View.GONE);
            tv.setVisibility(View.VISIBLE);
            tv.setText(R.string.conversationList_noOpenConversation);
        }

        // close the database after usage
        Log.e(TAG, "UpdateList end...");
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        if(requestCode==RESULT_CHAT) {

            int chats = getChats();

            if(chats==0) {
                finish();
            } else if(chats==1) {
                String jid;

                jid = getJid(0);

                if(lastJid.equals(jid)) {
                    finish();       
                } else {
                    show = false;
                }
            } else {
                show = false;
            }

        } else if (requestCode==RESULT_DIRECTCHAT) {
            finish();
        }
    }

    private void cancelNotification() {
        NotificationManager nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
        nm.cancel(Constants.NEW_MESSAGE_NOTIFICATION);
    }

    private void startChat(int pos) {
        String jid = getJid(pos);
        lastJid = jid;
        finishActivity(RESULT_CHAT);
        Intent i = new Intent(this, Conversations.class);
        i.putExtra("jid", jid);
        startActivityForResult(i, RESULT_CHAT);
        setResult(RESULT_OK);
        finish();
    }

    private void startChat(String jid) {
        finishActivity(RESULT_DIRECTCHAT);
        Intent i = new Intent(this, Conversations.class);
        i.putExtra("jid", jid);
        startActivityForResult(i, RESULT_DIRECTCHAT);
        setResult(RESULT_OK);
        finish();
    }

    private void closeChat(int pos) {
        SQLiteDatabase db = new JabberoidDbConnector(this).getWritableDatabase();
        db.delete(Constants.TABLE_CONVERSATION,
                Constants.TABLE_CONVERSATION_FIELD_CHAT + " = '" + getJid(pos) + "'",
                null);
        db.close();
        getChats();
        updateList(false);

    }

    private String getJid(int pos) {
        return chatList.get(pos);
    }

//  private void handleUpdateList() {

//  }

}
`

The error is here:

ListAdapter adapter = new ArrayAdapter<String>(
        this,
        R.layout.conversation_item,
        chatList
);
getListView().setAdapter(adapter);

No error when I remove it.

ListAdapter adapter = new ArrayAdapter<String>(
        this,
        R.layout.conversation_item,
        chatList
);
getListView().setAdapter(adapter);

What is the solution please?

conversation_item.xml

<?xml version="1.0" encoding="UTF-8"?>
 <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      xmlns:android="http://schemas.android.com/apk/res/android"

      android:id="@+id/conversation_item">

          <TextView 
              android:layout_height="wrap_content" 
              android:id="@+id/conversation_item_name" 
              android:text="Name Surname" 
              android:textColor="#ffffff" 
              android:textStyle="bold" 
              android:textSize="16dip" 
              android:layout_width="fill_parent" 
              android:layout_marginTop="10dip" 
              android:layout_marginBottom="10dip" 
              android:layout_marginLeft="10dip">
          </TextView>
          <TextView 
              android:layout_height="wrap_content" 
              android:id="@+id/conversation_item_date" 
              android:layout_width="fill_parent" 
              android:text="17.6.2010 15:30">
          </TextView>
          <TextView 
              android:layout_height="wrap_content"
              android:layout_width="fill_parent" 
              android:id="@+id/conversation_item_message" 
              android:text="Just some message..." 
              android:textColor="#ffffff">
          </TextView>   
</LinearLayout>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T00:22:51+00:00Added an answer on May 22, 2026 at 12:22 am

    I’m pretty sure the problem lies in your conversation_item layout. The docs state that you must provide a resource with a single TextView. What does that layout look like?

    As an example, this is what the simple_list_item_1 layout looks like, yours should be pretty similar.

    <?xml version="1.0" encoding="utf-8"?>
    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@android:id/text1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:gravity="center_vertical"
        android:paddingLeft="6dip"
        android:minHeight="?android:attr/listPreferredItemHeight"
    />
    

    EDIT:

    I just edited the question so your layout will show. Your layout is indeed wrong, you cannot have the linear layout there if you’re using that constructor. You can use the other constructor ( ArrayAdapter(Context context, int resource, int textViewResourceId, T[] objects) ) and provide your custom layout and your TextView’s id.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Try loading this normal .jpg file in Internet Explorer 6.0. I get an error
I generally try and keep all related entities in the same repository. The following
Like all developers with OCD I try to organise my namespaces within our project
I try to write a simple client/server application (all application is a bluetooth service
I try get the mp3 flash player to work with my javascript on all
We are using SQL 2005 and the try-catch functionality to handle all of our
I have this while loop in my code. The loop seems to work fine
This is a strange problem. I have two html pop-up windows, just hidden divs
So the other day, I asked this question about how to combine three complex
Good day, Stackoverflow! I have a little (big) problem with porting one of my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.