I implemented a custom Toolbar and in that custom toolbar, I implemented a custom editText to clear the data in the editText. So for drawable to work I implemented setDrawableClickListener
and it works but the problem is when the first time I click on drawable my editText get into text selection mode and drawable click doesn't work but the next time I click then drawable click works and clear the text.
So I need help to in implementing the drawable click work in the first time.
Link to custom editText: Setting onClickListener for the Drawable right of an EditText
So This time when I click the cross then editText blue cursor get visible and when this blue cross disappear after that when I click on the cross then editText gets cleared.
<android.support.v7.widget.Toolbar android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:contentInsetStart="0dp"
android:elevation="4dp"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/AlertDialog.AppCompat.Light"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:background="@color/colorPrimary"
android:padding="2.5dp"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.example.mybrowser.customEditText
android:drawableRight="@drawable/ic_clear_black_24dp"
android:drawablePadding="5dp"
android:inputType="textUri"
android:hint="Enter URL"
android:background="@drawable/rectangle"
android:id="@+id/urlEditText"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent" />
<Button
android:layout_margin="2dp"
android:background="@drawable/ic_send_black_24dp"
android:layout_width="50dp"
android:layout_height="50dp"
/>
</LinearLayout>
</android.support.v7.widget.Toolbar>