1I am trying to dynamically add widgets to my app for which I need the layout id, It is not present in the XML file, so I declared one and now when I am trying to access it using the "R.id.layoutid" it is showing as "not resolved" [screenshots][1][xml file]
Asked
Active
Viewed 41 times
-2
-
Doing invalidate cache/restart my fix it if it's a caching problem with Android Studio. – Tim Biegeleisen Jan 07 '18 at 10:26
-
Post your activity_main file – Ivan Wooll Jan 07 '18 at 10:42
-
posted the XML file – vaibnak Jan 07 '18 at 10:58
1 Answers
0
The layout id you are trying to access through R.id.myid
, is it part of your activity_main
layout, if not you need to specify the id in xml before accessing.
If you are trying to add a layout
dynamically then you need to inflate
the layout.
https://developer.android.com/reference/android/view/LayoutInflater.html

Durga M
- 534
- 5
- 17
-
yes I have declared the id as myid in XML file, i just want to add a button – vaibnak Jan 07 '18 at 10:40