2012-01-19 10 views
0

私はバッファリングされた文字列を持っており、それをImageViewに設定することでAndroidのImageとして表示したいと考えています。バッファー文字列をイメージに変換する方法は?

どうすれば教えていただけますか?

私のロジックは次のとおりです。

HttpEntity resEntity = responsePOST.getEntity();      
if (resEntity != null) { 
    buffer = new StringBuffer(""); 
    buffer.append(EntityUtils.toString(resEntity)); 
} 
byte []bt = buffer.toString().getBytes(); 
Bitmap i = BitmapFactory.decodeByteArray(bt, 0,bt.length); 
img.setImageBitmap(i); 

答えて

1

代わりにこの

byte []bt = buffer.toString().getBytes(); 
Bitmap i = BitmapFactory.decodeByteArray(bt, 0,bt.length); 

使用この

Bitmap i = BitmapFactory.decodeByteArray(buffer.getBytest or buffer.tobytes, 0,bt.length); 

の私はあなたのバッファが何であるかを知っているが、直接バイトを得る代わりに、文字列に変換してからバイトを取得しようといけません。

0

利用には、以下:

HttpEntity resEntity = responsePOST.getEntity();
バイト[] bt = EntityUtils.toByteArray(エンティティ);

ビットマップi = BitmapFactory.decodeByteArray(bt、0、bt.length); img.setImageBitmap(i);

+0

Thnx bro ... thnx a lot .. :) – nilesh

関連する問題