getLayoutInflater() in fragment

后端 未结 5 766
我寻月下人不归
我寻月下人不归 2020-12-04 17:27

I\'m trying to show my results search in a ListView on the Fragment, but it fails on:

LayoutInflater inflater = getLayoutInflater()         


        
5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-04 18:18

    If you want to inflate layout (attach child layout to parent) in Fragment

    Use this code

    LayoutInflater inflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    Now to Inflate child layout

    View view = inflater.inflate(R.layout.layout_child, null);
    

    Happy coding :)

提交回复
热议问题