안드로이드 개발 질문/답변
(글 수 45,052)
xmlpullparser를 이용해서
이미지경로와 타이틀을 ListView 에 파싱해오고
onItemClick 메소드로 ListView 클릭 시 상세화면으로 넘어가게했습니다
문제는 타이틀 값은 잘 받아오는데 이미지경로는 받아오지 못합니다
이미지경로는 정확한데ㅜ
검색해봐도 이미지파싱하는 방법은 있지만
이미지경로를 읽어와서 이미지를 띄우는 방법은없네요ㅜ
타이틀 파싱은 잘 되는 것으로 보아 파싱엔 문제가 없는 것 같습니다
어떻게 손을 대야 할 지 몰라서 소스 붙입니다 ㅜㅜ
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
Intent intent = new Intent(this, Menu_Info_Activity.class);
intent.putExtra("imgpath", list_ImgPath[arg2]);
intent.putExtra("title", list_Title[arg2]);
startActivity(intent);
}
}
class RowAdapter extends ArrayAdapter<String> {
// 작업에 필요한 Context 객체
Context context;
int resID;
String[] data;
public RowAdapter(Context c, int resID, String[] data) {
super(c, resID, data);
this.context = c;
this.resID = resID;
this.data = data;
}
// 실제 ListView의 항목을 만드는 메소드
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
if (row == null) {
Activity activity = (Activity) context;
LayoutInflater inflater = activity.getLayoutInflater();
// LayoutInflater 를 이용하여 View 객체 생성
row = inflater.inflate(R.layout.rows, null);
}
TextView textView = (TextView) row.findViewById(R.id.TextView01);
// 값 셋팅
textView.setText(data[position]);
return row;
}
}
getView가 잘못 된 걸까요 ㅜ
아래는 ListView항목 클릭 시 넘어오는 화면입니다
public class Menu_Info_Activity extends Activity {
ImageView iv;
TextView tv;
String imageUrl = "http: .jpg";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menu_info);
iv = (ImageView)findViewById(R.id.ImageView01);
tv = (TextView)findViewById(R.id.TextView01);
Intent i = getIntent();
Bundle extra = i.getExtras();
String imgpath = extra.getString("ImgPath");
String title = extra.getString("title");
tv.append("\n" + imgpath + "\n");
tv.append("\n" + title + "\n");
}
어디를 수정해야되나요 ㅜㅜ
2011.03.08 10:03:16
| URL imageURL = new URL(bookList.get(i).image); //이미지 URL 선언 URLConnection imgConn = imageURL.openConnection(); // URL 접근 InputStream is = imgConn.getInputStream(); BufferedInputStream bis = new BufferedInputStream(is); bmList.set(i,BitmapFactory.decodeStream(bis)); //ArrayList<Bitmap> bmList 에 비트맵 변환 저장 i 값은 포지션임 |
예전에 심심해서 네이버 API 이용해서 도서 검색한 거 만들었던거 소스 긁어왔습니다
소스만으로 충분하리라 생각됩니다




소스상에는.. put할때 키가 imgpath 이고
받을때는 대문자로 되어잇네여 ^^ ImgPath
소스상에서는 문제가 업어보이네여 오타만 수정해보세요