How to find a view
in a class
extended from Fragment
or ListFragmen开发者_运维知识库t
? If I try
Button newItemBtn = (Button)getView().findViewById(R.id.bt_add_item);
I do not receive my view back, meaning it was just not found. How to find it?
android fragment docs states :
View listView = getActivity().findViewById(R.id.list);
The answer is that you have to do it in onActivityCreated()
method, not in onCreate()
.
精彩评论