Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Use <code>Textwatcher</code> . <a href="http://developer.android.com/reference/android/text/TextWatcher.html" rel="nofollow">Click here more details</a></p> <pre><code>public class MainActivity extends Activity { ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;(); private EditText searchEdt; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // making it full screen requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_ugsimply_beta); list.add("Samsung Tab"); list.add("Samsung Note"); list.add("Nokia Lumia"); list.add("Nokia 5130"); list.add("Sony Xperia"); searchEdt = (EditText) findViewById(R.id.searchEdt); searchEdt.addTextChangedListener(new TextWatcher() { private int textlength; private ArrayList&lt;String&gt; arrayList_sort = new ArrayList&lt;String&gt;(); public void afterTextChanged(Editable s) { // Abstract Method of TextWatcher Interface. } public void beforeTextChanged(CharSequence s, int start, int count, int after) { // Abstract Method of TextWatcher Interface. } public void onTextChanged(CharSequence s, int start, int before, int count) { textlength = searchEdt.getText().length(); if (arrayList_sort != null) arrayList_sort.clear(); for (int i = 0; i &lt; list.size(); i++) { if (textlength &lt;= list.get(i).toString().length()) { if (searchEdt .getText() .toString() .equalsIgnoreCase( (String) list.get(i).toString() .subSequence(0, textlength))) { arrayList_sort.add(list.get(i)); Log.d("TAG", "log" + arrayList_sort.size()); } } } } }); } </code></pre> <p>}</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload