この URL を解析する方法
http://ioe.edu.np/exam/notices/8560Result%20Diploma%20I_I.jpg
imageview のソースとして使用できるようにします。Uri.encode() を使用してエンコードしようとしましたが、それは役に立ちませんでした。
以下は、URLから画像をロードするために参照しているコードです。Androidから取得し、ImageView の画像と同じ URL に画像を作成します
public class MainActivity extends Activity {
// String imageUrl1 = "http://java.sogeti.nl/JavaBlog/wp-content/uploads/2009/04/android_icon_256.png";
String imageUrl = Uri.encode("http://ioe.edu.np/exam/notices/8560Result Diploma I_I.jpg");
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try {
ImageView i = (ImageView) findViewById(R.id.imageView1);
Bitmap bitmap = BitmapFactory.decodeStream((InputStream) new URL(
imageUrl).getContent());
i.setImageBitmap(bitmap);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
私を助けてください。また、画像ファイルの名前を制御できないことに注意してください。そのため、画像ビューに正しく読み込まれるようにする方法を見つける必要があります。imageUrl を imageUrl1 に置き換えると、画像が読み込まれます。しかし、imageUrl では、スペースが html エンティティにエンコードされることに問題があるようです。これで私を助けてください。
ありがとうございました。