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 7417479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:42:38+00:00 2026-05-29T07:42:38+00:00

I have created a custom Cursor Adapter for my list.The list gets some data

  • 0

I have created a custom Cursor Adapter for my list.The list gets some data from a database

My problem is that my app force closes when i try to get to my activity and there is no item in the database to show.I would like to get a toast message if there is no entry in my database and not crash my app.

This is my logCat :

02-03 15:21:05.710: E/AndroidRuntime(24768): FATAL EXCEPTION: main
02-03 15:21:05.710: E/AndroidRuntime(24768): java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams
02-03 15:21:05.710: E/AndroidRuntime(24768):    at android.widget.ListView.clearRecycledState(ListView.java:513)
02-03 15:21:05.710: E/AndroidRuntime(24768):    at android.widget.ListView.resetList(ListView.java:500)
02-03 15:21:05.710: E/AndroidRuntime(24768):    at android.widget.ListView.layoutChildren(ListView.java:1534)
02-03 15:21:05.710: E/AndroidRuntime(24768):    at android.widget.AbsListView.onLayout(AbsListView.java:1863)
02-03 15:21:05.710: E/AndroidRuntime(24768):    at android.view.View.layout(View.java:11278)
02-03 15:21:05.710: E/AndroidRuntime(24768):    at android.view.ViewGroup.layout(ViewGroup.java:4224)
02-03 15:21:05.710: E/AndroidRuntime(24768):    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1628)
02-03 15:21:05.710: E/AndroidRuntime(24768):    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1486)
02-03 15:21:05.710: E/AndroidRuntime(24768):    at android.widget.LinearLayout.onLayout(LinearLayout.java:1399)
02-03 15:21:05.710: E/AndroidRuntime(24768):    at android.view.View.layout(View.java:11278)
02-03 15:21:05.710: E/AndroidRuntime(24768):    at android.view.ViewGroup.layout(ViewGroup.java:4224)
02-03 15:21:05.710: E/AndroidRuntime(24768):    at android.widget.FrameLayout.onLayout(FrameLayout.java:431)
02-03 15:21:05.710: E/AndroidRuntime(24768):    at android.view.View.layout(View.java:11278)
02-03 15:21:05.710: E/AndroidRuntime(24768):    at android.view.ViewGroup.layout(ViewGroup.java:4224)
02-03 15:21:05.710: E/AndroidRuntime(24768):    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1628)
02-03 15:21:05.710: E/AndroidRuntime(24768):    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1486)
02-03 15:21:05.710: E/AndroidRuntime(24768):    at android.widget.LinearLayout.onLayout(LinearLayout.java:1399)
02-03 15:21:05.710: E/AndroidRuntime(24768):    at android.view.View.layout(View.java:11278)
02-03 15:21:05.710: E/AndroidRuntime(24768):    at android.view.ViewGroup.layout(ViewGroup.java:4224)
02-03 15:21:05.710: E/AndroidRuntime(24768):    at android.widget.FrameLayout.onLayout(FrameLayout.java:431)
02-03 15:21:05.710: E/AndroidRuntime(24768):    at android.view.View.layout(View.java:11278)
02-03 15:21:05.710: E/AndroidRuntime(24768):    at android.view.ViewGroup.layout(ViewGroup.java:4224)
02-03 15:21:05.710: E/AndroidRuntime(24768):    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1489)
02-03 15:21:05.710: E/AndroidRuntime(24768):    at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442)
02-03 15:21:05.710: E/AndroidRuntime(24768):    at android.os.Handler.dispatchMessage(Handler.java:99)
02-03 15:21:05.710: E/AndroidRuntime(24768):    at android.os.Looper.loop(Looper.java:137)
02-03 15:21:05.710: E/AndroidRuntime(24768):    at android.app.ActivityThread.main(ActivityThread.java:4424)
02-03 15:21:05.710: E/AndroidRuntime(24768):    at java.lang.reflect.Method.invokeNative(Native Method)
02-03 15:21:05.710: E/AndroidRuntime(24768):    at java.lang.reflect.Method.invoke(Method.java:511)
02-03 15:21:05.710: E/AndroidRuntime(24768):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
02-03 15:21:05.710: E/AndroidRuntime(24768):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
02-03 15:21:05.710: E/AndroidRuntime(24768):    at dalvik.system.NativeStart.main(Native Method)
02-03 15:21:07.007: I/Process(24768): Sending signal. PID: 24768 SIG: 9

CODE:

public class Adapter extends CursorAdapter{    
     Cursor c;
     LayoutInflater inflater;
     Context context;

        public Adapter(Context context, Cursor c) {
            super(context, c);    
            this.c = c;
            this.context = context;
            inflater = LayoutInflater.from(context);
        }           
        @Override
            public View newView(Context context, Cursor cursor, ViewGroup parent) {
            View v = null;
         try{           
             v = inflater.inflate(R.layout.row, null);}             
             catch (Exception e) {
             e.printStackTrace();
            }
            return v;
        }
            @Override
              public void bindView(View view, final Context context, final Cursor cursor) {    
              final TextView txtName = (TextView) view.findViewById(R.id.textView01);
              txtName.setText(cursor.getString(cursor.getColumnIndex(DBHelper.NAME)));              
              ImageButton button = (ImageButton) view.findViewById(R.id.btn);
              button.setOnClickListener(new OnClickListener() {  

              public void onClick(View arg0) {    
                  Toast.makeText(context,"item Deleted", Toast.LENGTH_SHORT).show();                                   
           }
           });            
        }          
    }

RR.layout.row

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent" android:layout_height="wrap_content"
   android:background="#ffffff" android:gravity="center_vertical"
   android:orientation="horizontal">    

    <LinearLayout 
         android:layout_width="fill_parent"
         android:layout_height="wrap_content" android:orientation="vertical"
         android:layout_weight="1"  >
    <TextView 
         android:id="@+id/textView01" android:layout_width="wrap_content"
         android:layout_height="wrap_content" android:textColor="#000000"
         android:textSize="16dp" android:textStyle="bold"  />    
    <ImageButton 
         android:id="@+id/btn"
         android:layout_width="wrap_content" android:layout_height="wrap_content"
         android:background="@drawable/btn_bg" />
    </LinearLayout>

</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-29T07:42:38+00:00Added an answer on May 29, 2026 at 7:42 am

    you are passing wrong type as your LayoutParameters should be AbsListView.LayoutParams
    as it is written in your exception:

    ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a custom workflow activity that copies attachments from a case to
I have a custom CursorAdapter that is taking items from a database and displaying
We have created custom listview by using the Base adapter. List view contains Text
Have created a custom navigation menu in wordpress that has some pages and some
In my activity, I have an AutoCompleteTextView that gets its contents from my custom
I have created a custom list as a feature in sharepoint. i need to
I have created a custom tag that looks like this: def textField = {
I have created a custom module and am using hook_block to programmatically create some
I have created custom result class to serialize json data to xml. I want
I've created a custom adapter for my spinner because I wanted to have multiple

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.