how to run java and xml code (fetched from api) into another fragment

前端 未结 3 845
孤城傲影
孤城傲影 2020-11-30 16:00

okay I will breifly define what I exactly want.I\'m getting an java code(for textview, button,etc) from api like this--> image description here and Xml code(for textview, bu

3条回答
  •  情深已故
    2020-11-30 16:19

    There two way to add view dynamically .

    1. you create you xml file .then using LayoutInflater you lnflater that xml to your view .

    2. Or You can create view dynamically like var textview=TextView() then textview.text="xyz"

    You need relativelayout or linearlayout where will add those will using addView(); method.

    But i condition you have declare your view then you can customize at runtime.

    you can check the example

提交回复
热议问题