How to Inflate view from XML in Android?

后端 未结 3 1924
[愿得一人]
[愿得一人] 2020-12-06 17:16

I\'m creating a tableLayout [given in XML]

adding table Row [created in XML and inflating in Java]

also adding 2 textview to the table Row [created in XML an

3条回答
  •  忘掉有多难
    2020-12-06 17:31

    LayoutInflater inflater = (LayoutInflater)getApplicationContext().getSystemService      (Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.your_layout,null);
    mainlayout.addView(view;
    

    follow the above to inflate view.

提交回复
热议问题