I am using materialdatetime picker to create a form. If I am using TextView, It is working good, but I want to use EditText for it, I am uploading the image you can see if I am using EditText how it looks and if I am using TextView how it looks.But when using EditText I need to click twice to open the DatePicker. For first click it behaves like an editable textbox .
<!-- Adding Payment Method progress -->
<ProgressBar
android:id="@+id/payment_method_progress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:visibility="gone" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/adding_payment_method_heading"
android:textSize="@dimen/activity_heading"
android:elevation="0dp"
android:layout_marginBottom="@dimen/activity_vertical_margin"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/adding_payment_method_description"
android:textSize="@dimen/activity_description"
android:elevation="0dp"
android:layout_marginBottom="@dimen/activity_vertical_margin"
/>
<ScrollView
android:id="@+id/adding_payment_method_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/adding_payment_method_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/layout_user_id"
>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/enter_user_name"
android:inputType="text"
android:maxLines="1"
android:singleLine="true"
android:id="@+id/user_id" />
</android.support.design.widget.TextInputLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_weight="1"
android:text="Select Payment Methods" />
<Spinner
android:id="@+id/payment_methods"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/check_chosen"
>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/layout_amount"
>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/amount"
android:inputType="numberDecimal"
android:maxLines="1"
android:singleLine="true"
android:id="@+id/amount" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/layout_check_number"
>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/check_number"
android:inputType="number"
android:maxLines="1"
android:singleLine="true"
android:id="@+id/check_number" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/layout_bank_name"
>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/bank_name"
android:inputType="text"
android:maxLines="1"
android:singleLine="true"
android:id="@+id/bank_name" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/date_of_check"
android:layout_weight="1"
>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/check_date"
android:hint="Date"
android:inputType="date" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/layout_payment_info"
>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/payment_info"
android:inputType="text"
android:maxLines="1"
android:singleLine="true"
android:id="@+id/payment_info" />
</android.support.design.widget.TextInputLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/payment_date"
android:hint="@string/payment_date"
android:inputType="date" />
<Button
android:id="@+id/add_payment_method_action"
style="?android:textAppearanceSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="@string/submit"
android:onClick="testSubmit"
android:textStyle="bold" />
</LinearLayout>
</ScrollView>
</LinearLayout>
Please let me know, if I need to post the java code here.
put
android:focusable="false"
android:focusableInTouchMode="false"
in your edit text
UPDATE
add
android:longClickable="false"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With