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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:04:38+00:00 2026-06-15T07:04:38+00:00

I am filling ListView from the data fetched from Database . I am using

  • 0

I am filling ListView from the data fetched from Database. I am using a CustomAdapter which extends BaseAdapter for filling the ListView with data. Each row of the ListView contains 2 TextView and 1 CheckBox. Now what I want to do is place one EditText at the top of the Activity and when the user types some text for e.g J the ListView should show all the contacts starting with J. Please guide me.

CODE FOR MYCUSTOMADAPTER

public class MyCustomAdapter extends BaseAdapter {

Context mContext;
private LayoutInflater mInflater;
SparseBooleanArray mSparseBooleanArray;
private ArrayList<String> mData = new ArrayList<String>();
private ArrayList<String> mNumber = new ArrayList<String>();

public MyCustomAdapter(Context mContext) {
    mInflater = (LayoutInflater) mContext
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mSparseBooleanArray = new SparseBooleanArray();
}

public ArrayList<String> getCheckedItems() {
    ArrayList<String> mTempArry = new ArrayList<String>();
    for (int i = 0; i < mData.size(); i++) {
        if (mSparseBooleanArray.get(i)) {
            //mTempArry.add(mData.get(i));
            mTempArry.add(mNumber.get(i));
        }
    }
    return mTempArry;
}

public int getCount() {
    return this.mData.size();
}

public void addItem(String paramString1, String paramString2) {
    this.mData.add(paramString1);
    this.mNumber.add(paramString2);
    notifyDataSetChanged();
}

public Object getItem(int paramInt) {
    return (String) this.mData.get(paramInt);
}

public long getItemId(int paramInt) {
    return paramInt;
}

public View getView(final int paramInt, View paramView,
        ViewGroup paramViewGroup) {
    if (paramView == null) {
        paramView = mInflater.inflate(R.layout.multiplecontactview, null);
    }
    TextView txtName = (TextView) paramView.findViewById(R.id.txtContactName);
    TextView txtNumber = (TextView) paramView.findViewById(R.id.txtContactNumber);
    CheckBox mCheckBox = (CheckBox) paramView.findViewById(R.id.checkBox1);
    mCheckBox.setTag(paramInt);
    mCheckBox.setChecked(mSparseBooleanArray.get(paramInt));
    mCheckBox.setOnCheckedChangeListener(mCheckedChangeListener);
    txtName.setTextColor(Color.BLACK);
    txtNumber.setTextColor(Color.BLACK);
    for (int i = 0; i < mData.size(); i++) {
        txtName.setText(mData.get(paramInt).toString());
        txtNumber.setText(mNumber.get(paramInt).toString());
    }
    return paramView;
}

OnCheckedChangeListener mCheckedChangeListener = new OnCheckedChangeListener() {
    public void onCheckedChanged(CompoundButton buttonView,
            boolean isChecked) {
        mSparseBooleanArray.put((Integer) buttonView.getTag(), isChecked);
    }
};

public static class ViewHolder {
    public CheckBox cb;
    public TextView nameView;
    public TextView numberView;
}

}

CODE FOR FILLING LISTVIEW WITH DATA ONCREATE()

ArrayList<Contact> contacts = db.getAllContacts();
        for (Contact cn : contacts) {
            mAdapter.addItem(cn.getName(), cn.getPhoneNumber());
        }
        mAdapter.notifyDataSetChanged();
        mListView.setAdapter(mAdapter);
  • 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-15T07:04:40+00:00Added an answer on June 15, 2026 at 7:04 am

    I had to implement this for an App I made a while ago. Since it’s open source you can take a look at the code. I used SearchView for this.

    https://github.com/royale1223/HwaSettings

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

Sidebar

Related Questions

I am filling a ListView with data from my SQLite Database using a SimpleCursorAdapter.
In my applicatio i have 1 listview,filling data from database using arrayadapter. Here is
I am filling a GridView with the data table but on each row I
I am filling a listview from names of a database. That is all working
I am filling a form with the data from the selected row of a
I'm filling an XML document manually using C# and I need to have <data>
I am filling in my listview with a SimpleCursorAdapter . By using getView() I
I have a ListView than contains a list of image created from web link
I'm filling in a Word template with data that's been collected from user input.
I'm trying to bind data from my SQLiteDatabase to a ListView . I'm currently

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.