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

  • SEARCH
  • Home
  • 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 7552197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:42:00+00:00 2026-05-30T10:42:00+00:00

I have the issue… 02-20 02:57:09.854: E/AndroidRuntime(12431): Uncaught handler: thread main exiting due to

  • 0

I have the issue…

02-20 02:57:09.854: E/AndroidRuntime(12431): Uncaught handler: thread main exiting due to uncaught exception"

…later…

02-20 02:57:09.864: E/AndroidRuntime(12431): java.lang.ClassCastException: java.util.ArrayList

…in a ListView populated with SQLite, the listView works fine, but later when i try to use onListItemClick, to get the parameters of the item on the list view selected and show it in other layout, the program stops and the DDMS says this “Uncaught handler: thread main exiting due to uncaught exception” later says “java.lang.ClassCastException: java.util.ArrayList” in a ListView” maybe i handled bad my adapter of the Arraylist?

This is my main class:

public class lay_main extends ListActivity 
    {
    public ListView list;
public DBHelper myAdap;
protected SQLiteDatabase db;
public Cursor cursor;
DBHelper Context;
DBHelper ArrayList;

//adapter cAdapter class
protected ListAdapter adapter;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.lay_main);  

    collectXML();
    setupDataBase();
    setupAdapter();

}      
private void collectXML() 
{
     list = (ListView)findViewById(android.R.id.list);  

}

public void setupDataBase() {
    myAdap = new DBHelper(getApplicationContext());
    myAdap.insertCourses();             
}

public void setupAdapter()
{
if(myAdap.getCourses()!=null)
    {
    cAdapter adapter = new  cAdapter(this, R.layout.list_courses, myAdap.getCourses());
    list.setAdapter(adapter);
    }
}
public void onListItemClick(ListView parent, View view, int position, long id) 
 {
        super.onListItemClick(parent, view, position, id);
        Intent intent = new Intent(this, CourseDetails.class);
        Cursor cursor = (Cursor) myAdap.getItem(position);
        intent.putExtra("COURSE_ID", cursor.getInt(cursor.getColumnIndex("title")));
        startActivity(intent);  
 }
}

my class CourseDetails for receive and show the data:

public class CourseDetails<BDHelper> extends Activity {
protected TextView tTitle;
protected TextView tInstructor;
protected TextView tLength;
protected TextView tRating;
protected TextView tTopic;
protected TextView tSubject;
protected TextView tDescription;

protected  int courseId;    
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.course_details);

    courseId = getIntent().getIntExtra("COURSE_ID", 0);
    SQLiteDatabase db = (new DBHelper(this)).getWritableDatabase();
    Cursor cursor = db.rawQuery("SELECT title, instructor, length, rating, topic, subject, description FROM courses",         
            new String[]{"" + courseId});


    if (cursor.getCount() == 1)
    {
            cursor.moveToFirst();

            tTitle = (TextView) findViewById(R.id.tTitle);
            tTitle.setText(cursor.getString(cursor.getColumnIndex("title")));

            tInstructor = (TextView) findViewById(R.id.tInstructor);
            tInstructor.setText(cursor.getString(cursor.getColumnIndex("instructor")));

            tLength = (TextView) findViewById(R.id.tLength);
            tLength.setText(cursor.getString(cursor.getColumnIndex("length")));

            tRating = (TextView) findViewById(R.id.tRating);
            tRating.setText(cursor.getString(cursor.getColumnIndex("rating")));

            tTopic = (TextView) findViewById(R.id.tTopic);
            tTopic.setText(cursor.getString(cursor.getColumnIndex("topic")));

            tSubject = (TextView) findViewById(R.id.tSubject);
            tSubject.setText(cursor.getString(cursor.getColumnIndex("subject")));

            tDescription = (TextView) findViewById(R.id.tDescription);
            tDescription.setText(cursor.getString(cursor.getColumnIndex("description")));

    }


}}

My Adapter class:

public class cAdapter extends ArrayAdapter {
Context context;
ArrayList<Courses> courses;

@SuppressWarnings("unchecked")
public cAdapter(Context context, int layout_id, ArrayList<Courses> Courses) {

    super(context, layout_id, Courses);
    this.context=context;
    this.courses=Courses;


}

@Override
public View getView(int position, View convertView, ViewGroup parent)
{
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View row = inflater.inflate(R.layout.list_courses, null);
    try{
        //components
        TextView txt_title=(TextView)row.findViewById(R.id.txt_title);
        TextView txt_instructor=(TextView)row.findViewById(R.id.txt_instructor);
        TextView txt_length=(TextView)row.findViewById(R.id.txt_length);
        TextView txt_rating=(TextView)row.findViewById(R.id.txt_rating);
        TextView txt_topic=(TextView)row.findViewById(R.id.txt_topic);

        //asign values
        txt_title.setText(courses.get(position).title);
        txt_instructor.setText(courses.get(position).instructor);
        txt_length.setText(courses.get(position).length);
        txt_rating.setText(courses.get(position).rating);
        txt_topic.setText(courses.get(position).topic);

    }catch(Exception ex){}      
    return row;
}
}

not that I’m doing wrong, really would appreciate your help.

  • 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-30T10:42:02+00:00Added an answer on May 30, 2026 at 10:42 am

    Override getItem method of adapter and return Cources Object from getItem,

    Override
    public Courses getItem(int position)
    {
       return courses.get(positon);
    }
    

    and in SetupAdapter method:

    public void setupAdapter()
    {
    if(myAdap.getCourses()!=null)
        {
        adapter = new  cAdapter(this, R.layout.list_courses, myAdap.getCourses());
        list.setAdapter(adapter);
        }
    }
    

    and change on itemClick as follows:

    public void onListItemClick(ListView parent, View view, int position, long id) 
     {
            super.onListItemClick(parent, view, position, id);
            Intent intent = new Intent(this, CourseDetails.class);
            Courses course= (Courses) adapter.getItem(position);
            intent.putExtra("COURSE_ID", course.title));
            startActivity(intent);  
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have issue that is reproduced on g++. VC++ doesn't meet any problems. So
I have an issue that is driving me a bit nuts: Using a UserProfileManager
We have an issue using the PEAR libraries on Windows from PHP . Pear
We have an issue related to a Java application running under a (rather old)
We have an issue on our page whereby the first time a button posts
I have some issue with a Perl script. It modifies the content of a
I have an issue with using AWK to simply remove a field from a
I have big issue with url-rewriting for IIS 7.0. I've written simple module for
We have an issue with the way we are creating a Mutex . The
I have an issue with watin test that should browse for pdf and upload

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.