I am facing problem while filtration of list .I am using onTextChange() method for it .It is working properly but problem is that as i type single character in edit Text the soft keyboard gets disappear and I have to tap edit text again to type complete string .I have also done code so that soft keyboard does not disappear after text change but to type still I have to tap on edit text.Here is my code :
search.addTextChangedListener(new TextWatcher() {
@ Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// TODO Auto-generated method stub
String startwith = s.toString();
ArrayList < Myshares > filterList = new ArrayList < Myshares > ();
for (int i = 0; i < fileList.size(); i++) {
if (fileList.get(i).getName().toLowerCase().startsWith(startwith) || fileList.get(i).getName().toUpperCase().startsWith(startwith)) {
filterList.add(fileList.get(i));
}
}
adapter = new MListAdapter(PlayListActivity.this, filterList);
playListView.setAdapter(adapter);
adapter.notifyDataSetChanged();
}
@
Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
@
Override
public void afterTextChanged(Editable s) {
search.setSelection(search.getText().length());
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(search, InputMethodManager.SHOW_IMPLICIT);
}
});
here is my xml code for edit text:
<EditText
android:ems="10"
android:id="@+id/search_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="5dp"
android:layout_weight="2"
android:background="@drawable/searchbox"
android:editable="true"
android:focusable="true"
android:inputType="textFilter"
android:hint="Search"
android:keepScreenOn="true"
android:paddingLeft="10dp"
android:textSize="15dp" />
i have also set android:focusable="false " property on list view so that it doesn't overlap soft keyboard. But the problem with edit text is still same .Here are screenshots
As I insert A Single character list gets filter and cursor is gone from edit text box.