Constraintlayout Cannot Be Cast To Android.widget.textview
I keep getting a runtime error when I try to launch an activity. Line where the error happen: private OnItemClickListener mDeviceClickListener = new OnItemClickListener() { pub
Solution 1:
From the documentation:
View: The view within the AdapterView that was clicked (this will be a view provided by the adapter)
In your case the View
is the root ConstraintLayout
. And as the error says you can't cast it to TextView
. To get the info you can use:
String info = v.findViewById(R.id.textView).getText().toString()
Solution 2:
You just got wrong id for your constrain layout and mixed it up with textview that you have make declaration in MainActivity
Post a Comment for "Constraintlayout Cannot Be Cast To Android.widget.textview"