If I press any alphabet/number when application gets launched, EditText gets activated automatically and starts searching for the corresponding string.
For eg., On app launch, if user presses alphabet ‘A’ by mistake, EditText fetched that and shows all results starting from ‘A’.
Actually it should be activated and should display corresponding result if and only if a user clicks on EditText, and not otherwise.
I tried this in main.xml
android:focusable="false"
android:clickable="true"
and in activity class
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
lsym = (ListView) findViewById(R.id.lsym);
edsearch = (EditText) findViewById(R.id.edsearch);
dbM = new DbManager(this);
symbolarr = dbM.getSymbol();
edsearch.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
edsearch.setFocusable(true);
edsearch.requestFocus();
}
});
edsearch.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start,
int before, int count) {
//FILTERING LIST
}
});
}
, but it takes the focus away from EditText permanently and doesn’t get focus again even if it is clicked.
What am I doing wrong?
ANY HELP WILL BE LIFE-SAVER !!!
You should use below attributes for parent layout