This is an issue which I am facing only for > Android 4.0 devices.
Currently I have a listView and a custom header which I add onCreate()of the ListActivity.
I use the editText as a custom searchBar in the app.
The following is a code snippet which hopefully explains my implementation.
private ListView lst_Reports = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.showreportlist); lst_Reports = (ListView) findViewById(R.id.VuoShowReportsActivity_Lst_Reports); /* * Initialize UI */ LinearLayout headerView = (LinearLayout) View.inflate(this, R.layout.report_list_header, null); EditText reportSearchBar = (EditText) headerView.findViewById(R.id.reportSearchBar); lst_Reports.addHeaderView(headerView); reportSearchBar.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) { // do a search as and when the user inputs text if (s != null && s.length() > 0) { String query = s.toString(); List queriedReports = getReportsBasedOnQueryString(query); // populate the listView with the queriedReports } } }); } protected List getReportsBasedOnQueryString(String query) { // TODO Auto-generated method stub return null; }
When this code is executed on Android 2.3.5 device, then I can type normally in the editText. However when the same piece of code is deployed on Galaxy S3 which has Ice cream sandwich, I am able to only enter one character at a time in the editText since it keeps losing focus after every key input.
I have already tried the following proposed solutions to similar problems. None of them have solved the issue.
to the activity in AndroidManifest:
- android:windowSoftInputMode="stateHidden"
- android:windowSoftInputMode="adjustPan"
in the layout xml of the activity:
- android:descendantFocusability="beforeDescendants"
I appreciate any help/feedback on this and am also keen to know if anyone else has reported the same issue.
Thanks Rajat