Tag: android location

如何在活动类之外定义一个文本视图?

我有一个位置监听器对象,我想知道如何在活动类之外定义一个TextView。 在LayoutInflater.from(context).inflate(R.layout.main, null)我得到一个未解决的参考“上下文”和“主要”。 对于val locTextView = MainActivity.findViewById(R.id.locTextView) as TextView1我得到一个未解决的引用findViewById。 private val locationListener: LocationListener = object : LocationListener { override fun onLocationChanged(location: Location) { val v = LayoutInflater.from(context).inflate(R.layout.main, null) val locTextView = MainActivity.findViewById(R.id.locTextView) as TextView locTextView.setText("" + location.longitude + ":" + location.latitude); } override fun onStatusChanged(provider: String, status: Int, extras: Bundle) {} override fun onProviderEnabled(provider: String) […]