버튼을 누르면, 커서를 이동하여 하나씩 이미지를 보고 싶은데 한번에 이미지 다 변해 버리네요 (아래의 소스코드에서 이미지에 관한 커서는 reco_c입니다.) 이미지에 대한 이름을 reco_n에 받았는데 이미지는 한번에 변해버리고, 이름은 가장 마지막에 잇는 걸로 변해버리네요 해결법은 없나요?
>> 다음 버튼을 누르면 다음 커서로 이동하고, 이전 버튼을 누르면 이전 커서로 이동하고 싶습니다.
package com.jongjin.recommend;
import android.app.Activity;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.media.Image;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.RatingBar.OnRatingBarChangeListener;
import android.widget.TextView;
import android.widget.Toast;
public class RecoActivity extends Activity {
Recommand_DB recommand_db;
SQLiteDatabase DB_recommand;
Cursor reco_c;
Cursor reco_n;
RatingBar rate;
TextView tv01, tv02;
DownloadImageTask RecoImage;
ImageView img01;
Button btn01, btn02, btn03;
public String user; // 중요!! 인텐트로 값 넘겨서 현재 사용자 아이디를 넘겨줘야 한다.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_reco);
recommand_db = new Recommand_DB(this);
DB_recommand = recommand_db.getWritableDatabase();
rate = (RatingBar) findViewById(R.id.ratingBar1);
tv01 = (TextView) findViewById(R.id.textView1);
tv02 = (TextView) findViewById(R.id.reconame);
img01 = (ImageView) findViewById(R.id.recoImage);
btn01 = (Button) findViewById(R.id.prev);
btn02 = (Button) findViewById(R.id.next);
btn03 = (Button) findViewById(R.id.redo);
rate.setStepSize(1);
rate.setRating(0);
rate.setIsIndicator(false);
btn02.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
GetImage();
}
});
rate.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {
@Override
public void onRatingChanged(RatingBar ratingBar, float rating,
boolean fromUser) {
// TODO Auto-generated method stub
tv01.setText("평점 :" + rating);
// 별점을 디비에 저장해야한다.
// SaveScore(rating);
}
});
}
/*
* public void SaveScore(float score, String str1) { reco_c =
* DB_recommand.rawQuery(
* "SELECT star_score FROM db_recommand where id=recommand_logo", null);
*
* if (reco_c != null && reco_c.getCount() != 0) { reco_c.moveToFirst();
* while (reco_c.moveToNext()) { int star =
* reco_c.getInt(reco_c.getColumnIndex("star_score")); if (star == 0) {
* String now = reco_c.getString(reco_c .getColumnIndex("recommand_name"));
* RecoUpdate(now, score);
*
* } } } }
*/
/*
* public void RecoUpdate(String reco_name, float score) { DB_recommand =
* recommand_db.getWritableDatabase(); ContentValues values = new
* ContentValues(); values.put("star_score", score);
* DB_recommand.update("db_recommand", values, "recommand_name=?", new
* String[] { reco_name }); Toast.makeText(getApplicationContext(),
* reco_name + "평점 " + score + "점" + "을 추가하였습니다.", 1).show();
*
* }
*/
public void GetImage() {
reco_c = DB_recommand.rawQuery(
"select recommand_logo from db_recommand", null);
reco_n = DB_recommand.rawQuery(
"select recommand_name from db_recommand", null);
if (reco_c != null && reco_c.getCount() != 0) {
if (reco_c.moveToFirst()) {
do {
String uri = reco_c.getString(reco_c
.getColumnIndex("recommand_logo"));
RecoImage = (DownloadImageTask) new DownloadImageTask(
(ImageView) findViewById(R.id.recoImage))
.execute(uri);
Toast.makeText(getApplicationContext(), "왜 안되!1", 1).show();
} while (reco_c.moveToNext());
}
if (reco_n.moveToFirst()) {
do {
String rname = reco_n.getString(reco_n
.getColumnIndex("recommand_name"));
tv02.setText(null);
tv02.setText(rname);
Toast.makeText(getApplicationContext(), "왜 안되!3", 1).show();
} while (reco_n.moveToNext());
}
}
Toast.makeText(getApplicationContext(), "왜 안되!2", 1).show();
}
}