私はコーディングに不慣れで、テキストアドベンチャーに取り組んでおり、画像ビューで場所に基づいて画像を変更したいのですが、どのように機能し、なぜこのソリューションが機能しないのか疑問に思いました。プレイヤーの位置に基づいてそれを行う方が良いでしょうか?問題が発生しているので、どこでその情報を探すことができますか。ありがとう
<room>
<east>1</east>
<description>Room 1(0)</description>
<ImageView
android:id="@+id/ImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/bedroom"
/>
</room>
<room>
<east>2</east>
<west>0</west>
<description>Room 2(1)</description>
<ImageView
android:id="@+id/imagePlace1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/living"
/>
</room>
<room>
<west>1</west>
<description>Room 3(2)</description>
<ImageView
android:id="@+id/imagePlace2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/kitchen"
/>
</room>```
1つのimageviewのみを使用し、場所に基づいて画像を変更すると便利です
画像を変更するには、次のJavaコードを使用します。
imageview_object.setImageResource(R.drawable.image_name);
画像がres/drawable
フォルダ内にあることを確認してください
また、緯度と対数で位置を取得するには、このリンクhttps://javapapers.com/android/get-current-location-in-android/をたどることができます。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加