0
私は4つのボタンを持っています.... 各ボタンは画像です.... 次のボタンを押すと画像を変更したい,,, どうすればいいですか?私のプロジェクトは、それが変更についてのヘルプのURL >>>>>感謝からのロード10枚の写真:)4画像をアンドロイドのURLから読み込む方法は?
public void onClick(View arg0) {
// TODO Auto-generated method stub
new LoadImage().execute("http://pbs.twimg.com/profile_images/630285593268752384/iD1MkFQ0.png");
new LoadImag().execute("http://pbs.twimg.com/profile_images/630285593268752384/iD1MkFQ0.png");
new LoadIm().execute("http://pbs.twimg.com/profile_images/630285593268752384/iD1MkFQ0.png");
new LoadIma().execute("http://pbs.twimg.com/profile_images/630285593268752384/iD1MkFQ0.png");
}
});
}
private class LoadImage extends AsyncTask<String, String, Bitmap> {
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(MainActivity.this);
pDialog.setMessage("Loading Image ....");
pDialog.show();
}
protected Bitmap doInBackground(String... args) {
try {
bitmap = BitmapFactory.decodeStream((InputStream)new URL(args[0]).getContent());
} catch (Exception e) {
e.printStackTrace();
}
return bitmap;
}
protected void onPostExecute(Bitmap image) {
if(image != null){
img.setImageBitmap(image);
pDialog.dismiss();
}else{
pDialog.dismiss();
Toast.makeText(MainActivity.this, "Image Does Not exist or Network Error", Toast.LENGTH_SHORT).show();
}
}
}
private class LoadImag extends AsyncTask<String, String, Bitmap> {
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(MainActivity.this);
pDialog.setMessage("Loading Image ....");
pDialog.show();
}
protected Bitmap doInBackground(String... args) {
try {
bitmap = BitmapFactory.decodeStream((InputStream)new URL(args[0]).getContent());
} catch (Exception e) {
e.printStackTrace();
}
return bitmap;
}
protected void onPostExecute(Bitmap image) {
if(image != null){
b1.setImageBitmap(image);
pDialog.dismiss();
}
}
}
private class LoadIm extends AsyncTask<String, String, Bitmap> {
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(MainActivity.this);
pDialog.setMessage("Loading Image ....");
pDialog.show();
}
protected Bitmap doInBackground(String... args) {
try {
bitmap = BitmapFactory.decodeStream((InputStream)new URL(args[0]).getContent());
} catch (Exception e) {
e.printStackTrace();
}
return bitmap;
}
protected void onPostExecute(Bitmap image) {
if(image != null){
b2.setImageBitmap(image);
pDialog.dismiss();
}
}
}
private class LoadIma extends AsyncTask<String, String, Bitmap> {
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(MainActivity.this);
pDialog.setMessage("Loading Image ....");
pDialog.show();
}
protected Bitmap doInBackground(String... args) {
try {
bitmap = BitmapFactory.decodeStream((InputStream)new URL(args[0]).getContent());
} catch (Exception e) {
e.printStackTrace();
}
return bitmap;
}
protected void onPostExecute(Bitmap image) {
if(image != null){
b3.setImageBitmap(image);
pDialog.dismiss();
}
}
}
}
使用 'Picasso'ライブラリ:
は、あなただけのこの行を必要とします。 –