Inflator in Android Application Development

前端 未结 4 1627
自闭症患者
自闭症患者 2021-02-14 14:10

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条回答
  •  無奈伤痛
    2021-02-14 14:53

    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

提交回复
热议问题