私のアプリケーションにはリストビューがあります.各行には相対的なレイアウトで画像とテキストビューが含まれています..すべてが完了しました..しかし、リストビューはネイティブの「連絡先リスト」ほどスムーズにスクロールしません.問題はgetviewにあると思います. (),y このメソッドには「HTTP」呼び出しとビットマップ画像の読み込みがあるため..これを行う方法はありますか..助けてください..事前に感謝します..
私の Getview メソッド:
public View getView(int position, View convertView, ViewGroup parent)
{
// TODO Auto-generated method stub
Bitmap bitmap = DownloadImage(
kickerimage[position] );
// View listView = convertView;
ViewHolder holder;
if (convertView == null)
{
//this should only ever run if you do not get a view back
LayoutInflater inflater = (LayoutInflater) contxt
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.homelistrow, null);
holder = new ViewHolder();
holder.image = (ImageView) convertView
.findViewById(R.id.icon);
holder.image.setImageBitmap(bitmap);
holder.text = (TextView) convertView
.findViewById(R.id.name_label);
holder.text.setText(itemsarray[position]);
}
return convertView ;
}
private Bitmap DownloadImage(String URL)
{
// System.out.println("image inside="+URL);
Bitmap bitmap = null;
InputStream in = null;
try {
in = OpenHttpConnection(URL);
bitmap = BitmapFactory.decodeStream(in);
in.close();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
// System.out.println("image last");
return bitmap;
}
private InputStream OpenHttpConnection(String urlString)
throws IOException
{
InputStream in = null;
int response = -1;
URL url = new URL(urlString);
URLConnection conn = url.openConnection();
if (!(conn instanceof HttpURLConnection))
throw new IOException("Not an HTTP connection");
try{
HttpURLConnection httpConn = (HttpURLConnection) conn;
httpConn.setAllowUserInteraction(false);
httpConn.setInstanceFollowRedirects(true);
httpConn.setRequestMethod("GET");
httpConn.connect();
response = httpConn.getResponseCode();
if (response == HttpURLConnection.HTTP_OK)
{
in = httpConn.getInputStream();
}
}
catch (Exception ex)
{
throw new IOException("Error connecting");
}
return in;
}