何が起こっているかを簡単に説明します。 1つのimageViewを更新して別の名前の描画可能イメージに変更したい4つの選択肢があります。これは、別のアクティビティから選択した4つの国の選択肢を持つスピナーからデータを取り出すためです。これにより、imageViewが当該国のカスタム描画可能イメージに変更されます。文字列内のデータ(単語など)に基づいてイメージビューの表示イメージを変更する
これまでのところ、私はこれをどうやってやろうとしているのかよく分かりませんが、非常に基本的なif else文を試しましたが、非常に間違っています。
私は以下の持っているものをいくつか投稿します:
public class WorldImage extends AppCompatActivity {
TextView textCountry;
private String stringCountry;
ImageView imageCountry;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_worldimage);
Intent aIntent = getIntent();
stringCountry = aIntent.getStringExtra("movetoImageActivity");
textCountry= (TextView) findViewById(R.id.movetoviewCountry);
imageCountry = (ImageView) findViewById(R.id.imageCountry);
それは私が迷子にこの辺りだ、のようないくつかの本当に基本的な他の場合& if文、:
if (textCountry.getText().toString().equals("Europian Union"))
{
imageCountry.setImageResource(R.drawable.eu_flag);
}
何だろうがここにお奨めですか?
を、でもデバッグエラー – Hervel
[OK]を、これはイン実際の作業を行うを与えることなくクラッシュ非常によく、ありがとう! – Hervel