ImageView
をsetImageResource
と設定しようとしていますが、機能しません。何もエラーはありません。 logcatは正常に見えます。私はと呼ばれる別のレイアウトからImageView
を宣言することを考えるとsetImageResourceが機能しない
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);
}
:
は、ここに私のコードです。別のレイアウトのイメージを設定するために2つのレイアウトを膨張させると問題になりますか?
ここに間違いがありますか?
あなたはinflatとイメージリソースを設定した後、メインレイアウトに別のビューレイアウトを追加しますか? –
いいえ、別のビューを最初に展開してからイメージを設定します。 ビュービュー= inflater.inflate(R.layout.fragment_item_list_request、container、false); setHasOptionsMenu(true); 他のビューを表示= inflater.inflate(R.layout.style_fragment_list_request、container、false); imgView =(CircleImageView)anotherView.findViewById(R.id.listPhoto); imgView.setImageResource(R.drawable.pastel_red); } – Borom1r
別のビューを追加する必要があります。そうでない場合は、表示されません。 –