相关疑难解决方法(0)

TextInputLayout onclick中的EditText需要2次点击?!Android的

我只是试图在TextInputLayout中的一个编辑文本上单击一下.它工作,但我需要点击EditText两次,它触发我不明白为什么.这是我的代码:

XML:

  <android.support.design.widget.TextInputLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp">

        <EditText
            android:id="@+id/start_date"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:ems="10"
            android:hint="Starting Date*: "
            android:inputType="textPersonName" />
    </android.support.design.widget.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)

Listenner:

   private void setListenners() {
        EditText startDate = (EditText) mView.findViewById(R.id.start_date);
        startDate.setOnClickListener(new View.OnClickListener() {
            @RequiresApi(api = Build.VERSION_CODES.N)
            @Override
            public void onClick(View v) {
                Calendar mcurrentDate=Calendar.getInstance();
                int mYear = mcurrentDate.get(Calendar.YEAR);
                int mMonth = mcurrentDate.get(Calendar.MONTH);
                int mDay = mcurrentDate.get(Calendar.DAY_OF_MONTH);

                DatePickerDialog mDatePicker=new DatePickerDialog(getActivity(), new DatePickerDialog.OnDateSetListener() {
                    @Override
                    public void onDateSet(DatePicker datePicker, int year, int month, int day) {
                        Log.d("DEBUG", "year: " + year + " month: " …
Run Code Online (Sandbox Code Playgroud)

android onclicklistener

19
推荐指数
2
解决办法
8184
查看次数

标签 统计

android ×1

onclicklistener ×1