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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:19:22+00:00 2026-06-02T07:19:22+00:00

Here is my Custom Adapter : public View getView(int position, View convertView, ViewGroup parent)

  • 0

Here is my Custom Adapter :

public View getView(int position, View convertView, ViewGroup parent) {

    View row = super.getView(position, convertView, parent);


    Cursor cursbbn  = getCursor();



    if (row == null)

    {

        LayoutInflater inflater = (LayoutInflater) localContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        row = inflater.inflate(R.layout.listtype, null);
    }


    String Title = cursbbn.getString(2);
    String Readyin = cursbbn.getString(4);
    String Faovoites=cursbbn.getString(8);


    TextView titler=(TextView)row.findViewById(R.id.listmaintitle);
    TextView readyinr=(TextView)row.findViewById(R.id.listreadyin);

     int colorPos = position % colors.length;
     row.setBackgroundColor(colors[colorPos]);

    titler.setText(Title);
    readyinr.setText(Readyin);

    ImageView picture = (ImageView) row.findViewById(R.id.imageView1);
    Bitmap bitImg = BitmapFactory.decodeResource(localContext.getResources(), R.drawable.seafood);

    if(Title.contentEquals("Fajita Raps"))
        picture.setImageBitmap(getRoundedCornerImage(bitImg));


    if (Faovoites.contentEquals("YES")) {

        ImageView star = (ImageView) row.findViewById(R.id.favoritesicon);
        star.setVisibility(View.VISIBLE);

    }

    return row;
}

And This is my Search Edittext aftertextchanged event

public void afterTextChanged(final Editable s) {

            final String[] columns = new String[] {

            "_id", COL_SanID, COL_SanTitle, COL_SanCat, COL_SanReadyin,

            COL_SandServing, COL_SandIngred, COL_SandDirect, COL_SandFavor };

            Bundle extrass = getIntent().getExtras();

            final String Type = extrass.getString("CategoryType");

            mAdapter.setFilterQueryProvider(new FilterQueryProvider() {
                public Cursor runQuery(CharSequence constraint) {

                    String value = "%" + constraint + "%";
                    String Type2 = "%" + Type + "%";

                    curs = mDb.query(TABLE_NAME, columns, COL_SanTitle
                            + " LIKE ? And " + COL_SanCat + " LIKE ?",
                            new String[] { value, Type2 }, null, null,
                            COL_SanTitle + " ASC");

                    return curs;

                }
            });

and Finally : Logcat exceptions

04-26 18:56:50.310: E/AndroidRuntime(878): FATAL EXCEPTION: main
04-26 18:56:50.310: E/AndroidRuntime(878): android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 1
04-26 18:56:50.310: E/AndroidRuntime(878): at android.database.AbstractCursor.checkPosition(AbstractCursor.java:580)
04-26 18:56:50.310: E/AndroidRuntime(878): at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:214)
04-26 18:56:50.310: E/AndroidRuntime(878): at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:41)
04-26 18:56:50.310: E/AndroidRuntime(878): at master.chef.mediamaster.Interface.onItemClick(Interface.java:781)
04-26 18:56:50.310: E/AndroidRuntime(878): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
04-26 18:56:50.310: E/AndroidRuntime(878): at android.widget.ListView.performItemClick(ListView.java:3513)
04-26 18:56:50.310: E/AndroidRuntime(878): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1812)
04-26 18:56:50.310: E/AndroidRuntime(878): at android.os.Handler.handleCallback(Handler.java:587)
04-26 18:56:50.310: E/AndroidRuntime(878): at android.os.Handler.dispatchMessage(Handler.java:92)
04-26 18:56:50.310: E/AndroidRuntime(878): at android.os.Looper.loop(Looper.java:123)
04-26 18:56:50.310: E/AndroidRuntime(878): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-26 18:56:50.310: E/AndroidRuntime(878): at java.lang.reflect.Method.invokeNative(Native Method)
04-26 18:56:50.310: E/AndroidRuntime(878): at java.lang.reflect.Method.invoke(Method.java:507)
04-26 18:56:50.310: E/AndroidRuntime(878): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-26 18:56:50.310: E/AndroidRuntime(878): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-26 18:56:50.310: E/AndroidRuntime(878): at dalvik.system.NativeStart.main(Native Method)

  • 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-06-02T07:19:26+00:00Added an answer on June 2, 2026 at 7:19 am

    In getView() when you call localCursor.moveToPosition(position); you get java.lang.IllegalStateException: attempt to re-open an already-closed object: android.database.sqlite.SQLiteQuery.

    Why this happens? Because once filtering has been applied to the list view, the old cursor is closed and the new one is used instead. You can get the current underlying cursor by calling getCursor() instead of tracking the initial one. Get rid of Cursor localCursor and use getCursor() instead.

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

Sidebar

Related Questions

here is my getView method of my custom adapter: public View getView(int position, View
Here's the code I'm using to make a custom AlertDialog. public void onButtonClicked(View v)
I have made a custom adapter class here is the code public class CustomArrayAdapterForReceipts
Trying to set up a gridview with a custom adapter, I get my cursor
I have a listview with custom array adapter, the view allows the user to
I have a Listview with custom cursor adapter. I'm trying to prevent input in
I have a custom adapter. Within my getView() , I'm trying to populate holder.contact
I have used a custom array adapter to populate my list view.The problem i
Here is my custom List view layout. I've added an empty list text view
I need a little help with my custom list view adapter. I'm using the

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.