【发布时间】:2014-08-14 08:03:45
【问题描述】:
我正在尝试在布局中设置图像资源/drawable。但是,当我设置图像时,输出中没有显示图像,也没有看到错误。
View rootView = inflater.inflate(R.layout.fragment_card_layout, container, false);
LayoutInflater layoutInflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
cardView = layoutInflater.inflate(R.layout.recent_conversions_list, null);
ListView listView = (ListView) rootView.findViewById(android.R.id.list);
...
ImageView imageView = (ImageView) cardView.findViewById(R.id.unit_icon_ring);
imageView.setImageResource(R.drawable.ic_angle_icon);
...
return rootView;
还值得指出的是,我正在为其设置图像资源的 ImageView 不包含在片段中使用的主布局中。 R.layout.fragment_card_layout 将 R.layout.recent_conversions_list 设置为列表项。
【问题讨论】: