0

drawable フォルダー内の画像をギャラリー ビューに表示しました。マイコード

public class GalleryView extends Activity {
Integer[] pics = {
  R.drawable.antartica1,
  R.drawable.antartica2,
  R.drawable.antartica3,
  R.drawable.antartica4,
  R.drawable.antartica5,
  R.drawable.antartica6,
  R.drawable.antartica7,
  R.drawable.antartica8,
  R.drawable.antartica9,
  R.drawable.antartica10
};
ImageView imageView;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Gallery ga = (Gallery)findViewById(R.id.Gallery01);
    ga.setAdapter(new ImageAdapter(this));

    imageView = (ImageView)findViewById(R.id.ImageView01);
    ga.setOnItemClickListener(new OnItemClickListener() {



public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
 long arg3) {
Toast.makeText(getBaseContext(), 
  "You have selected picture " + (arg2+1) + " of Antartica", 
  Toast.LENGTH_SHORT).show();
imageView.setImageResource(pics[arg2]);

}

    });

}



}

しかし、私はこのような配列リストに画像を持っています

[http://sport24x7.com/nightclub/photos/ 9955917512-Gym-ChestWorkout_xxlarge.jpg, http://sport24x7.com/nightclub/photos/ 64557264beginner_gym_workout_legs_large.jpg, http://sport24x7.com/nightclub/photos/ 54809160intro-ez-bar.jpg]

これらの画像をギャラリー ビューで表示する方法。誰でもこれを行うのを手伝ってもらえますか?

4

3 に答える 3

0

ギャラリービューは非推奨であり、今後は使用しないでください。

GridView を使用して画像を表示する方法に関する簡単なチュートリアルを次に示します。

getView重要な概念は、イメージをオーバーライドしてImageView. Picassoを使用して、URL を指定して画像を簡単に読み込むことができます。

たとえば、アダプタのgetView:

Picasso.with(context).load("http://i.imgur.com/DvpvklR.png").into(imageView);
于 2015-02-11T06:51:41.340 に答える
0

画像をダウンロードしてから、Gallery で表示する必要があります。UIL
の使用をお勧めします

于 2015-02-11T06:06:33.073 に答える