我即将ImageView
设置为setImageResource
,但它无效。也没什么错误。并且logcat看起来很好。
这是我的代码:
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_item_list_request, container, false);
setHasOptionsMenu(true);
View anotherView = inflater.inflate(R.layout.style_fragment_list_request,container,false);
imgView = (CircleImageView)anotherView.findViewById(R.id.listPhoto);
imgView.setImageResource(R.drawable.pastel_red);
}
考虑到我从另一个布局调用并声明了ImageView
。如果我为另一个布局的设置图像充气2个布局会有问题吗?
这里有什么不对吗?
答案 0 :(得分:0)
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_item_list_request, container, false);
setHasOptionsMenu(true);
return view;
}
public void onActivityCreated(){
ViewGroup layout = (ViewGroup) getView().findById(R.id.layout_another_view); // need layout for anotherView in fragment_item_list_request.xml
View anotherView = inflater.inflate(R.layout.style_fragment_list_request,container,false);
imgView = (CircleImageView)anotherView.findViewById(R.id.listPhoto);
imgView.setImageResource(R.drawable.pastel_red);
layout.addView(anotherView);
}
答案 1 :(得分:0)
如果你这样做会怎么样:
git revert <badCommitHash1> <badCommitHash2> <badCommitHash3>...
答案 2 :(得分:0)
语句返回anotherView; 在onCreateView()中缺失。