I have copied one youtube url and tried to paste that youtube url in the edittext on the very first click which is inside the alert dialog and it doesn't works.
But it works on second click, also I have checked the clipboard manager to check the content is copied or not and I can read the copied content in clipboard object.
please find the below xml code of mine did I missed something or please let me know what kind of solution that I need to follow to fix this issue. I have looking into this issue for past 2 days to get this fix but nothing works out.
xml code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/frame_view"
android:layout_width="match_parent"
android:layout_height="64dp"
android:background="@color/colorPrimary"
android:scaleType="center">
<TextView
android:id="@+id/dialog_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="@string/title"
android:textAllCaps="true"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="@color/white"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="@+id/view_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/frame_view"
android:orientation="vertical">
<LinearLayout
android:orientation="horizontal"
android:padding="@dimen/dimen_size_20dp"
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<EditText
android:gravity="center"
android:id="@+id/dialog_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:maxLines="1"
android:textColor="@color/black"
android:textColorHint="@color/dark_gray"
android:hint="@string/video_link"
/>
<LinearLayout
android:orientation="horizontal"
android:padding="@dimen/dimen_size_20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/view_layout"
android:orientation="horizontal">
<Button
android:visibility="visible"
android:id="@+id/dialog_cancel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/ripple_effect"
android:text="@string/cancel"
android:textColor="@color/white" />
<View
android:id="@+id/view_divider"
android:visibility="visible"
android:background="@color/white"
android:layout_width="@dimen/dimen_size_1dp"
android:layout_height="match_parent"/>
<Button
android:id="@+id/dialog_save"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/ripple_effect"
android:text="@string/save"
android:textColor="@color/white" />
</LinearLayout>
It is work second time because first time it is focus then second time click event works.
Try this code:
<EditText
android:focusable="false"
...
/>