サーバーから画像を表示したい。実際には、段落を表示し、それとともに画像を表示する必要があります。これにはリスト ビューを選択しました。現在、段落を表示していますが、画像を表示しようとすると機能しません。これに関して私を助けてください...
私のコード:
private class ListAdapter extends ArrayAdapter<UserBO> {
--
--
--
-- public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
try {
if (view == null) {
LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = vi.inflate(R.layout.list_item, null);
// --CloneChangeRequired(list_item)
}
final UserBO listItem = mList.get(position); // --CloneChangeRequired
if (listItem != null) {
--
--
--
--
imageUrl = "http://server.com//folder/"+ array.get(0);
((TextView) view.findViewById(R.id.description))
.setText(listItem.getdesc()));
downloadFile(imageUrl);
----
--
}
}
}
}
void downloadFile(String fileUrl) {
URL myFileUrl = null;
try {
myFileUrl = new URL(fileUrl);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
HttpURLConnection conn = (HttpURLConnection) myFileUrl
.openConnection();
conn.setDoInput(true);
conn.connect();
int length = conn.getContentLength();
InputStream is = conn.getInputStream();
bmImg = BitmapFactory.decodeStream(is);
imView.setImageBitmap(bmImg);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}