Searching of Customlist view not working
<p>I am trying to built search functionality on custom listView but it is not working..list is not changing according to EditText words changes..</p>

<p>listplaceholder.xml</p>

<pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"&gt;

&lt;EditText 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/edtSearch"
    android:hint="Search"/&gt;
    &lt;ListView
    android:id="@id/android:list"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:drawSelectorOnTop="false" /&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p>my_custom_layout.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp" &gt;

&lt;ImageView
    android:id="@+id/imageView1"
    android:layout_width="70dp"
    android:layout_height="70dp"
    android:src="@drawable/icon" /&gt;

&lt;FrameLayout
    android:id="@+id/frame"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" &gt;

    &lt;Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="Button"
        /&gt;

    &lt;LinearLayout
        android:id="@+id/ll1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@drawable/a"
        android:orientation="vertical" &gt;

        &lt;TextView
            android:id="@+id/from_user"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="#000000" /&gt;

        &lt;TextView
            android:id="@+id/from_user_id"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="#000000" /&gt;
    &lt;/LinearLayout&gt;
&lt;/FrameLayout&gt;

&lt;/LinearLayout&gt;
</code></pre>

<p>Main.java</p>

<pre><code>public class Main extends ListActivity {
/** Called when the activity is first created. */
ImageView img, img1;
private AdapterClass adapter;
private String reviewImageLink;

private static final String TAG = "PRANJAL";
private boolean isImage = false;

String fileName[] = new String[10];
private String imgurl;

ArrayList&lt;HashMap&lt;String, String&gt;&gt; searchResult;
private EditText edtSearch;
private ListView list;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.listplaceholder);
    edtSearch = (EditText) findViewById(R.id.edtSearch);
    list = (ListView) findViewById(android.R.id.list);
    // list = (LinearLayout) findViewById(R.id.list);
    final ArrayList&lt;HashMap&lt;String, String&gt;&gt; mylist = new ArrayList&lt;HashMap&lt;String,        String&gt;&gt;();

    JSONObject json = JSONfunctions
            .getJSONfromURL("http://23.21.228.8/PlutoApp_Beta/consumer_dash/"
                    + "checkIn_confirmation_related_record.php?lat=18.535787&amp;lng=73.891889");
    try {

        JSONArray earthquakes = json.getJSONArray("Display");
        for (int i = 0; i &lt; earthquakes.length(); i++) {
            HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();

            JSONObject e = earthquakes.getJSONObject(i);

            map.put("Name", e.getString("name"));
            map.put("Vicinity", e.getString("vicinity"));

            map.put("logo", e.getString("logo"));

            imgurl = e.getString("logo");

            // Toast.makeText(getApplicationContext(), imgurl,
            // Toast.LENGTH_SHORT).show();

            imgurl = e.getString("logo");

            // Toast.makeText(getApplicationContext(), imgurl,
            // Toast.LENGTH_SHORT).show();

            DownloadFromUrl(imgurl, i + ".jpg");
            reviewImageLink = imgurl;// getString(R.string.ImageURI);
            URL reviewImageURL;
            fileName[i] = reviewImageLink.substring(reviewImageLink
                    .lastIndexOf("/") + 1);

            // map.put("profile_image_url", fileName[i]);

            map.put("logo", i + ".jpg");

            list.setTextFilterEnabled(true);
            mylist.add(map);
        }
    } catch (JSONException e) {
        Log.e("log_tag", "Error parsing data " + e.toString());
    }

    /*final ListView lv = getListView();
    lv.setTextFilterEnabled(true);*/

    searchResult = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;(mylist);

    // adapter = new AdapterClass(Main.this, R.layout.main, mylist);
    adapter = new AdapterClass(Main.this, R.layout.my_custom_layout, mylist);

    // list.setAdapter(adapter);
    setListAdapter(adapter);

    edtSearch.addTextChangedListener(new TextWatcher() {

        public void onTextChanged(CharSequence s, int start, int before,
                int count) {
            // get the text in the EditText
            String searchString = edtSearch.getText().toString();
            int textLength = searchString.length();
            searchResult.clear();

            for (int i = 0; i &lt; mylist.size(); i++) {
                String playerName = mylist.get(i).get("Name").toString();

                if (textLength &lt;= playerName.length()) {
                    // compare the String in EditText with Names in the
                    // ArrayList
                    if      (searchString.equalsIgnoreCase(playerName.substring(
                            0, textLength)))
                        Toast.makeText(getApplicationContext(),
                                "Inside if of : " +    playerName, 1000)
                                .show();
                    searchResult.add(mylist.get(i));
                }

            }
            adapter.notifyDataSetChanged();

        }

        public void beforeTextChanged(CharSequence s, int start, int count,
                int after) {

        }

        @Override
        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub

        }

    });

    /*
     * final ListView lv = getListView(); //lv.setTextFilterEnabled(true);
     * lv.setOnItemClickListener(new OnItemClickListener() { public void
     * onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id)
     * {
     * 
     * @SuppressWarnings("unchecked") HashMap&lt;String, String&gt; o =
     * (HashMap&lt;String, String&gt;) lv .getItemAtPosition(position);
     * 
     * } });
     */
}

public void DownloadFromUrl(String DownloadUrl, String fileName) {

    try {
        File dir = new File("/sdcard/pluto");

        if (dir.exists() == false) {
            dir.mkdirs();
        }

        URL url = new URL(DownloadUrl); // you can write here any link
        File file = new File(dir, fileName);

        long startTime = System.currentTimeMillis();
        Log.d("DownloadManager", "download begining");
        Log.d("DownloadManager", "download url:" + url);
        Log.d("DownloadManager", "downloaded file name:" + fileName);

        /* Open a connection to that URL. */
        URLConnection ucon = url.openConnection();

        /*
         * Define InputStreams to read from the URLConnection.
         */
        InputStream is = ucon.getInputStream();
        BufferedInputStream bis = new BufferedInputStream(is);

        /*
         * Read bytes to the Buffer until there is nothing more to read(-1).
         */
        ByteArrayBuffer baf = new ByteArrayBuffer(5000);
        int current = 0;
        while ((current = bis.read()) != -1) {
            baf.append((byte) current);
        }

        /* Convert the Bytes read to a String. */
        FileOutputStream fos = new FileOutputStream(file);
        fos.write(baf.toByteArray());
        fos.flush();
        fos.close();
        Log.d("DownloadManager",
                "download ready in"
                        + ((System.currentTimeMillis() - startTime) / 1000)
                        + " sec");

    } catch (IOException e) {
        Log.d("DownloadManager", "Error: " + e);
    }

}

}
</code></pre>

<p>Please Help me.</p>
