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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:45:04+00:00 2026-05-27T06:45:04+00:00

This code basically fetches data from database and display it in a list along

  • 0

This code basically fetches data from database and display it in a list along with a searchbox which helps in filtering out specific values from list.

Please check this snapshot!

http://imgur.com/MpkXe

But the problem is DataAttach.java is extended from Activity which doesn’t support onListItemClick().

If I want to include onListItemClick(),
I must extend the class from ListActivity instead of Activity.

Here comes the problem.
If I extend the class from ListActivity, I can’t include the searchbox in my view.

I’m stuck into deadlock, any suggestions appreciated. Thanks.

DataAttach.java(snippet):

                    symbolarr = dbM.getSymbol();

                    if (symbolarr != null) {
                        list1 = new String[symbolarr.length];

                        for (int i = 0; i < symbolarr.length; i++) {
                            list1[i] = symbolarr[i];
                        }
                    }

                    // ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                    // android.R.layout.simple_list_item_1, symbolarr);
                    // setListAdapter(adapter);

                    lv.setAdapter(new ArrayAdapter<String>(this,
                            android.R.layout.simple_list_item_1, symbolarr));

DbManager.java(snippet)

            public String[] getSymbol() {
                Cursor cur;
                try {
                    cur = mDb.rawQuery("select symbol,company_name from scrip", null);
                } catch (SQLiteException e) {
                    throw new Error(" *** ERROR in cursor *** " + e.getMessage());
                }

                String[] b1 = new String[1326];
                int x = 0;
                if (cur.moveToFirst()) {
                    do {
                        b1[x] = cur.getString(cur.getColumnIndex("symbol"));
                        x++;
                    } while (cur.moveToNext());
                }
                cur.close();
                return b1;
            }

main.xml

    < LinearLayout android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical"
    android:id="@+id/MainLayout">

    < EditText android:id="@+id/txt1" 
    android:layout_height="wrap_content" 
    android:layout_width="fill_parent" 
    android:hint="Search">
    < /EditText>

    < ListView android:id="@+id/list"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >
    < /ListView>

    < /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-27T06:45:04+00:00Added an answer on May 27, 2026 at 6:45 am

    You can actually go either way:

    1. Define a ListActivity with custom layout: http://developer.android.com/reference/android/app/ListActivity.html Note that you MUST set id like this @android:id/list.

    2. Without ListActivity: use setOnItemClickListener(AdapterView.OnItemClickListener listener) on your ListView.

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

Sidebar

Related Questions

I'm trying to modify the code from this script . Basically I'm trying to
I have a button on my ASP.NET page, which fetches some data from my
I am trying to work out how to parallelize some code from data mining
I've got this code which basically loops through a set of folders and subfolders
So I have found this code here This basically lets me pull some data
This code basically translates characters based on position in one string to the character
Basically this code below returns the right information, but I need to add the
So basically this code was working fine before. I had some computer issues and
I recently came across this in some code - basically someone trying to create
I am using this code to alter the title of an image. Basically it

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.