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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:24:22+00:00 2026-05-18T01:24:22+00:00

I have an alert dialog which lists around 100 cities. Is there a way

  • 0

I have an alert dialog which lists around 100 cities. Is there a way to search within it? Or maybe autocomplete?

alt text

I want to add a textbox which will filter the list according to what I type.

EDIT: I’m very SORRY. What I meant was that I wanted to FILTER the above list based on what I type in a textbox. For example if I type ‘D’, I should get only Dhaka..

  • 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-18T01:24:22+00:00Added an answer on May 18, 2026 at 1:24 am

    Ok I finally managed to do it using a custom Dialog.

    citylistview.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout android:id="@+id/LinearLayout01"
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_height="fill_parent"
        android:layout_width="200dip" 
        android:orientation="vertical"
        android:gravity="center">
        <EditText android:id="@+id/EditBox" 
            android:maxLines="1"
            android:layout_height="wrap_content"
            android:layout_width="180dip"
            android:gravity="left">
        </EditText> 
        <ListView android:id="@+id/List"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:choiceMode="singleChoice">
        </ListView>
    </LinearLayout>
    

    CityListDialog.java

    public class CityListDialog extends Dialog implements OnClickListener {
    
    private ListView list;
    private EditText filterText = null;
    ArrayAdapter<String> adapter = null;
    private static final String TAG = "CityList";
    
    public CityListDialog(Context context, String[] cityList) {
        super(context);
    
        /** Design the dialog in main.xml file */
        setContentView(R.layout.citylistview);
        this.setTitle("Select City");
        filterText = (EditText) findViewById(R.id.EditBox);
        filterText.addTextChangedListener(filterTextWatcher);
        list = (ListView) findViewById(R.id.List);
        adapter = new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, cityList);
        list.setAdapter(adapter);
        list.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> a, View v, int position, long id) {
                Log.d(TAG, "Selected Item is = "+list.getItemAtPosition(position));
            }
        });
    }
    @Override
    public void onClick(View v) {
    
    }
    private TextWatcher filterTextWatcher = new TextWatcher() {
    
        public void afterTextChanged(Editable s) {
        }
    
        public void beforeTextChanged(CharSequence s, int start, int count,
                int after) {
        }
    
        public void onTextChanged(CharSequence s, int start, int before,
                int count) {
            adapter.getFilter().filter(s);
        }
    };
    @Override
    public void onStop(){
        filterText.removeTextChangedListener(filterTextWatcher);
    }}
    

    This is the results I get when I call the dialog. Thanks everyone. alt text

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

Sidebar

Related Questions

I have a startActivity which shows an alert dialog until my downloading and parsing
I have an alert dialog being popped, which allows a person to enter a
I have a custom alert dialog, in which i set a list view and
I have a Login dialog that can create an alert dialog when the user
I have a simple list view with some check boxes in an alert dialog.
I have an alert dialog (image and text in each row), but it is
I am working on list Preferences,have to increase the font size in Alert Dialog
In my program I have used an alert dialog box on onclick event. But
I am invoking a jquery modal dialog in which I have a save button.
I have a bit of a problem with a jQuery dialog and the way

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.