您的位置:首页 > 其它

LayoutInflater的用法

2015-07-17 10:09 375 查看
Instead of doing

convertView = infalInflater.inflate(R.layout.list_item, null);


do

convertView = infalInflater.inflate(R.layout.list_item, parent, false);


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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: