天天看點

LayoutInflater的用法

Instead of doing

do

It will inflate it with the given parent, but won’t attach it to the parent.

為Fragment添加主題:

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), R.style.Theme_PageIndicatorDefaults);  
        LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapper);
        rootView = localInflater.inflate(R.layout.fragment_packet, null);
        rootView.findViewById(R.id.btn_operate).setOnClickListener(this);

        initFrame();
        return rootView;
    }