Inflator in Android Application Development

前端 未结 4 1929
不知归路
不知归路 2021-02-14 14:30

Can anybody please tell What Inflator is and how it is being used in an Android application?

I don\'t know the exact use of it and Why it is being used.

4条回答
  •  旧时难觅i
    2021-02-14 15:04

    you were asking for use of Inflator.. basically when you want to use two xml files in one java class ,inflator is used and its code is simple which is given below..

     TextView text;
        View layout;
            LayoutInflater inflator=getLayoutInflater();
            layout =inflator.inflate(R.layout.new_xml_that you want to use in that java class,null);
    
            text=(TextView)layout.findViewById(R.id.text);
            text.setText("progressing");
    

    here i use textview,this is present in next xml with id=text thats it.. if you find this worthy then please like this.. thanks

提交回复
热议问题