设置edittext在小米设备上不起作用...科特琳

时间:2019-12-10 13:41:39

标签: android kotlin android-edittext xiaomi

在小米设备上无法设置EditText
在大多数设备上,我可以在除Xioami之外的所有设备上正常运行的应用程序(三星,LG,Oneplus,华为,Xioami)上测试该应用程序。 由于某些原因,Xioami设备无法设置或获取以下代码: tripTimeEditText?.setText(_diffResultDouble.toString())

感谢帮助

fun TimePickerDialogFun (){
        val _calender = Calendar.getInstance()

        val _timePicer = TimePickerDialog(this,TimePickerDialog.OnTimeSetListener { view, hourOfDay, minute ->
            _timePicByUser.set(Calendar.HOUR_OF_DAY,hourOfDay)
            _timePicByUser.set(Calendar.MINUTE,minute)
            if(_checkButtomTimePush == 1){
                startTimeButton.text = _timeFormat.format(_timePicByUser.time)
                _timeStart.set(Calendar.HOUR_OF_DAY,hourOfDay)
                _timeStart.set(Calendar.MINUTE,minute)

            }else if(_checkButtomTimePush == 2){
                endTimeButton.text = _timeFormat.format(_timePicByUser.time)
                _timeEnd.set(Calendar.HOUR_OF_DAY,hourOfDay)
                _timeEnd.set(Calendar.MINUTE,minute)
            }else{
                _checkButtomTimePush = 0
            }

            try {
                var _format = SimpleDateFormat("hh:mm:ss aa")
                var _time1 = _format.parse("08:00:12 pm")
                var _time2 = _format.parse("05:30:12 pm")
                 _difreentBetweenTime = _time2.time - _time1.time
                _time1 = _timeStart.time
                _time2 = _timeEnd.time
                _difreentBetweenTime = _time2.time - _time1.time
                 _hours = (_difreentBetweenTime / (1000 * 60 * 60)).toInt()
                 _mins = (_difreentBetweenTime / (1000 * 60)).toInt() % 60
                _diffResultDouble = (_hours * 60 + _mins).toDouble()
                 _diffResultString = "$_hours:$_mins"

                tripTimeEditText?.setText(_diffResultDouble.toString())

            } catch (e: Throwable) {
                e.printStackTrace()
            }
        },
            _calender.get(Calendar.HOUR_OF_DAY),
            _calender.get(Calendar.MINUTE),true
        )
        _timePicer.show()

1 个答案:

答案 0 :(得分:0)

我发现了问题 我更改了代码的这一部分,一切开始在xioami设备上工作

来自:

public synchronized void start() {
        /**
         * This method is not invoked for the main method thread or "system"
         * group threads created/set up by the VM. Any new functionality added
         * to this method in the future may have to also be added to the VM.
         *
         * A zero status value corresponds to state "NEW".
         */
        if (threadStatus != 0)
            throw new IllegalThreadStateException();

        /* Notify the group that this thread is about to be started
         * so that it can be added to the group's list of threads
         * and the group's unstarted count can be decremented. */
        group.add(this);

        boolean started = false;
        try {
            start0();
            started = true;
        } finally {
            try {
                if (!started) {
                    group.threadStartFailed(this);
                }
            } catch (Throwable ignore) {
                /* do nothing. If start0 threw a Throwable then
                  it will be passed up the call stack */
            }
        }
    }

                var _format = SimpleDateFormat("hh:mm:ss aa")
                var _time1 = _format.parse("08:00:12 pm")
                var _time2 = _format.parse("05:30:12 pm")