-2

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]

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
vaibnak
  • 467
  • 3
  • 13

1 Answers1

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

How to inflate a layout dynamically?

Durga M
  • 534
  • 5
  • 17