How to get selected ListItem in ListView(Android)?
<p>I'm new to android. </p>

<p>I have worked in searchbar using Listview and it's working fine, but I want to get selected ListItem from ListView. Please any one help me.</p>

<p>Thanks.</p>

<p>I tried the source code:
     private ListView lv1;
     private EditText ed;
     SitesList sitesList = null;</p>

<pre><code>        private String lv_arr[] = {"sam","priya","rahul",};

        private ArrayList&lt;String&gt; arr_sort= new ArrayList&lt;String&gt;();
        int textlength=0;

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

    //   index = lv1.getSelectedItemPosition();
    //     selObj = lv1.getSelectedItem();
    //   System.out.println("selObj "+ selObj );

        lv1=(ListView)findViewById(R.id.ListView01);
        ed=(EditText)findViewById(R.id.EditText01);

         sitesList = MyXMLHandler.sitesList;
         String LoginToken = sitesList. getCourtName().toString();
         System.out.println("ResultLoginToken" + LoginToken);

        lv1.setAdapter(new ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_list_item_1, lv_arr));
        ed.addTextChangedListener(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)
        {

        textlength=ed.getText().length();
        arr_sort.clear();
        for(int i=0;i&lt;lv_arr.length;i++)
        {
        if(textlength&lt;=lv_arr[i].length())
        {
        if(ed.getText().toString().equalsIgnoreCase((String) lv_arr[i].subSequence(0, textlength)))
        {
        arr_sort.add(lv_arr[i]);
        }
        }
        }

        lv1.setAdapter(new ArrayAdapter&lt;String&gt;(Searchbar.this,android.R.layout.simple_list_item_1, arr_sort));
        }
        });
        }
        }
</code></pre>
