且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Kotlin中写入EditText时遇到问题

更新时间:2023-01-23 18:20:31

好,但是使用kotlinextension是一种更好的方法,我认为您需要做两件事可以解决您的问题

Ok, But using kotlinextension is a better way to do this, I think you need to do 2 things may solve your problem

第一

import kotlinx.android.synthetic.main.activity_main2.*

我认为您已经完成了

,而不是通过findViewById直接用作

second instead of initializing your Editext by findViewById direct use as

fun setZipEdit(zipEdit:String){
        Log.d("SZE",zipEdit)
        Log.d("mzh",mZipHold.toString())
         zipHolder.setText(zipEdit)

         //mZipHold.setText(zipEdit,TextView.BufferType.EDITABLE)

    }

您可以仅通过使用其ID来访问您的视图.让我们试试看,让我知道是否可行

you can access your views by only use their id. Let try this and let me know if works