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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:29:18+00:00 2026-06-10T18:29:18+00:00

If there was just one value in a row. I got the answer but

  • 0

If there was just one value in a row. I got the answer but i have more than one.

This my main class which i couldnt decide how to fill Textwatcher stuff. “CityArray” is the class which i created the rows and “CityXmlParse” is the class that i take data from XML file called “cities.xml” in the raw folder. Each row has an image and a name and i want to filter the rows by name while typing, but whole row must be seen after typing (with image).

public class TravelFinalActivity extends Activity {

EditText sc;
ListView lv;
List<CityData> citylist;
CityArray adapter;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    sc = (EditText) findViewById(R.id.citySearch);

    CityXmlParse cityParse = new CityXmlParse();
    InputStream in = getResources().openRawResource(R.raw.cities);
    cityParse.xmlParse(in);

    citylist = cityParse.getList();        
    adapter = new CityArray(getApplicationContext(),R.layout.city_row, citylist);      
    lv = (ListView) this.findViewById(R.id.cityList);
    lv.setAdapter(adapter);      
    lv.setTextFilterEnabled(true);        

    sc.addTextChangedListener(new TextWatcher() {

        public void onTextChanged(CharSequence s, int start, int before, int count) {
            // TODO Auto-generated method stub


        }

        public void beforeTextChanged(CharSequence s, int start, int count,
                int after) {
            // TODO Auto-generated method stub

        }

        public void afterTextChanged(Editable s) {
                // TODO Auto-generated method stub
       }
  });   

}
}

And here is the class for xml parsing.

public class CityXmlParse{

private final List<CityData> list = new ArrayList<CityData>();


private String getNodeValue(NamedNodeMap map, String key) {
    String nodeValue = null;
    Node node = map.getNamedItem(key);
    if (node != null) {
        nodeValue = node.getNodeValue();
    }

  return nodeValue;
}

public List<CityData> getList(){
    return this.list;
}


public void xmlParse(InputStream in){
try {
    DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    Document doc = builder.parse(in, null);
    NodeList cityList = doc.getElementsByTagName("city");

    for(int i=0; i<cityList.getLength(); i++){

    final NamedNodeMap cityAttr = cityList.item(i).getAttributes();
    final String cityName=getNodeValue(cityAttr, "name");
    final String cityInfo=getNodeValue(cityAttr, "info");   

    CityData cityObj = new CityData(cityName, cityInfo, cityName + ".png");

    list.add(cityObj);  

    }       
}catch (Throwable T) {}

}

}

Finally this is my “CityArray” constructor and the method for customing row.

public CityArray(Context context, int textViewResourceId, List<CityData> citylist) {
    super(context, textViewResourceId, citylist);
    this.citylist=citylist;
    this.context=context;
}

public View getView(int position, View convertView, ViewGroup parent) {
    View rowView = convertView;
    if(rowView == null){
        inflater = (LayoutInflater) this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        rowView = inflater.inflate(R.layout.city_row, parent,false);
    } 

    CityData cityObj = getItem(position);

    cityImage = (ImageView) rowView.findViewById(R.id.city_image);      
    cityName = (TextView) rowView.findViewById(R.id.city_name);

    String imgPath = ASSETS_DIR + cityObj.resourceImg;      
    try {
        Bitmap bitmap = BitmapFactory.decodeStream(this.context.getResources().getAssets().open(imgPath));
        cityImage.setImageBitmap(bitmap);
    } catch (IOException e) {
        e.printStackTrace();
    }

    cityName.setText(cityObj.name);     

    return rowView;
}

Thanks in advance!

  • 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-10T18:29:19+00:00Added an answer on June 10, 2026 at 6:29 pm
    • Making Items in an ArrayAdapter filterable: ArrayAdapter has a
      built in ArrayFilter , It compares the Objects in adapter list by
      using a string from toString().toLowerCase() for each object. If
      you override toString() in CityData class and return city name,
      then ArrayAdapter should be able to filter items effectively.

    • Enabling Automatic text filter on a ListView: In ListView either use android:textFilterEnabled="true" in layout or set it from code using setTextFilterEnabled(true). Now whenever listView is in focus, user can simply bring up the keyboard, and start typing, list items will be automatically filtered.

    • Explicitly setting text filter on a ListView: Use setFilterText() method of ListView. Do not forget to clear this afterward.

    You can reveal more details by examining the relevant Android Sources.

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

Sidebar

Related Questions

I just want to show more than one Watch window. There, they say that
This one might be a bit basic and easy to answer, but I've been
I have a GridView with 4 images per row, and normally has more than
Hey guys, I'm working on a status-Updater. It works, there is just one problem,
The page I'm building depends heavily on AJAX. Basically, there is just one page
Is there a way to recieve the complete nameserver set by passing just one
Is there an easy way of running a JQuery script just on one specific
Just a quick one about installing a PHP website, are there any tools out
Is there a one-line easy linq expression to just get everything from a simple
So I just saw a weird behavior In one script there is something like:

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.