C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Android EditText with TextWatcher (Searching data from ListView)Android EditText is a subclass of TextView. EditText is used for entering and modifying text. While using EditText width, we must specify its input type in inputType property of EditText which configures the keyboard according to input. EditText uses TextWatcher interface to watch change made over EditText. For doing this, EditText calls the addTextChangedListener() method. Methods of TextWatcher
Example of EditText with TextWatcher()In this example, we will implement EditText with TextWatcher to search data from ListView. activity_main.xmlCreate an activity_main.xml file in layout folder containing EditText and ListView. File: activity_main.xml Create another file list_item.xml in layout folder which contains data of ListView. list_item.xmFile: list_item.xml Activity classActivity class package com.example.test.searchfromlistview; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; import android.widget.ArrayAdapter; import android.widget.EditText; import android.widget.ListView; import android.support.v7.app.AppCompatActivity; import android.widget.Toast; public class MainActivity extends AppCompatActivity { private ListView lv; private EditText editText; private ArrayAdapter Output
Next TopicAndroid Life Cycle of Activity
|