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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:09:11+00:00 2026-06-17T09:09:11+00:00

I have a ListView with custom Adapter and I create the TextView using Vector

  • 0

I have a ListView with custom Adapter and I create the TextView using Vector
I want to show only the country that contains the letter “a” for example.
and I can’t find the solution to do this.

Here is my adapter and how I tried to do it

public class CountryAdapter extends BaseAdapter {
protected MainActivity main = new MainActivity();
private Context mContext;
protected Vector<Country> mVector;
protected SQLiteDatabase mDb;
Cursor cursor;
ImageView deleteIt;
View rowView;
public int pos;


public void setmContext(Context mContext) {
    this.mContext = mContext;
}

public CountryAdapter(Context mContext) {
    this.mContext = mContext;

    mVector = new Vector<Country>();

    CountryOpenHelper helper = new CountryOpenHelper(mContext);
    mDb = helper.getWritableDatabase();

    cursor = mDb.rawQuery("SELECT * FROM COUNTRIES", null);

    if (cursor.getCount() > 0) {

        cursor.moveToFirst();
    }
    do {
        Country country = new Country();
        country.setmCountryIndex(cursor.getInt(0));

        country.setmCountryName(cursor.getString(2));
        country.setmCountryTextSize(cursor.getInt(1));
        country.setmCountryColor(cursor.getInt(3));
        mVector.add(country);
        for (int i = 0; i < cursor.getCount(); i++){
            if (mVector.get(i).toString().contains("a") == false){
                mVector.remove(i);
            }
        }

    } while (cursor.moveToNext());

And if required here is my GetView method thats in my CountryAdapter too :

public View getView(int position, View convertView, ViewGroup parent) {
    TextView tv;
    if(convertView == null){
        tv = new TextView(mContext);
    }else{
        tv = (TextView) convertView;
    }

    this.pos = position;

    tv.setText(mVector.get(position).getmCountryName());
    tv.setTextColor(mVector.get(position).getmCountryColor());
    tv.setTextSize(mVector.get(position).getmCountryTextSize());

    return tv;




}
  • 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-17T09:09:12+00:00Added an answer on June 17, 2026 at 9:09 am

    I recommend changing directions a bit: use the built-in SimpleCursorAdapter or a custom CursorAdapter. Cursors and CursorAdapters are more efficient and resilient than converting a Cursor into a Vector or any other type of List. They also provider access to the FilterQueryProvider class which will filter the Cursor for you.

    Try out this basic tutorial.

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

Sidebar

Related Questions

We have created custom listview by using the Base adapter. List view contains Text
I have a custom listview row that contains a number of textView components. Instead
I have a ListView with a custom Adapter that extends ArrayAdapter. It's a ArrayAdapter
I have a custom adapter for my ListView which has multiple TextViews. I want
I would like to create ListView using CustomAdapter that extends BaseAdapter . I have
I have a ListView with a custom list adapter (that extends BaseAdapter). My list
I have a custom listview adapter which contains ArrayList as a member. Each game
I have created custom listview in that have list of textview & list of
I have a custom listview adapter which contains two buttons, the problem is it's
I have a ListView with a custom Adapter that creates rows containing TextViews that

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.