How do I start a new activity when the user touches an EditText like in the Facebook search and Google search widget?

Setting setOnClickListener works only after the first click. On the first click the EditText becomes highlighted, and keyboard pops up. On second click it opens the new activity. I do not want this, instead I want to open the activity on the very first click. How do I do it?


Answer :

You need to disable the EditText’s focus in touch mode, that will make the onclick execute on the first tap:

<EditText ...