私のアプリケーションのハイスコアリストを作成しようとしています。 このリストはSQLデータベースに基づいています。名前を保存して、スコアがうまくいきます。 リストビューは、この行のXMLファイルに基づいています。SimpleCursorAdapterに設定されているListViewのImageViewのリソースを変更する方法
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingTop="4dip"
android:paddingBottom="6dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView android:id="@+id/NAME_CELL"
android:layout_width="250dip"
android:layout_height="wrap_content"
android:textSize="20dip" />
<TextView android:id="@+id/SCORE_CELL"
android:layout_width="20dip"
android:layout_height="wrap_content"
android:textSize="20dip" />
<ImageView android:id="@+id/PICTURE_CELL"
android:layout_width="50dip"
android:layout_height="20dip"
android:src="@drawable/no_picture" />
そして私は、プレーヤーが10のスコアに達した場合、たとえばPICTURE_CELL ImageViewのイメージを表示する必要があることを望みます。 は、今の私は、ハイスコアのためにデータベースを経由して見えているカーソルがあります。
public void drawPictures()
{
if (dbCursor.moveToFirst()) {
do
{
if(dbCursor.getInt(2)<=4)
{
Log.d(TAG, "no picture");
}
else if((dbCursor.getInt(2) > 4) && (dbCursor.getInt(2) <= 9))
{
Log.d(TAG, "picture1");
}
else if((dbCursor.getInt(2) > 9) && (dbCursor.getInt(2) <= 19))
{
Log.d(TAG, "picture2");
}
else if(dbCursor.getInt(2) > 20)
{
Log.d(TAG, "picture3");
}
}
while (dbCursor.moveToNext());
をしかし、私は、各行内のすべてのImageViewののリソースを変更することができますか見当がつかない。 私を助けてください、これは数日間私を殺しています!
ありがとうございます!
あなたは本当に "dbCursor.getInt(2)" このようなメッセージを避ける必要があります良い練習ではありません。2つではなく、行を識別するデータベースヘルパーから公開されたString Constantを持つ必要があります。 – JoxTraex