如何在对话框中打开图像

时间:2011-03-03 23:09:00

标签: android

今天早些时候我发布了一个关于如何从一个图库中打开图像的问题。一位成员回答我按照本教程http://www.androidpeople.com/android-gallery-imageview-example/ ...我现在的问题是,我想在一个对话框中打开图像没有我的画廊。这可能吗?谢谢

 private Integer[] mImageIds = {
            R.drawable.a,
            R.drawable.aa,
            R.drawable.aaa,
            R.drawable.aaaa

    };
      /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        setContentView(R.layout.main);

        imgView = (ImageView)findViewById(R.id.ImageView01);
        imgView.setImageResource(mImageIds[0]);

       Gallery g = (Gallery) findViewById(R.id.gallery);
     g.setAdapter(new ImageAdapter(this));

        g.setOnItemClickListener(new OnItemClickListener() {

            public void onItemClick(AdapterView parent, View v, int position, long id) {
                 imgView.setImageResource(mImageIds[position]);         }
        });

1 个答案:

答案 0 :(得分:1)

尝试Dialog课程。它类似于活动:

new Dialog(this) {
    @Override
    public onCreate(Bundle unused) {
        ImageView myImage = new ImageView(getContext());
        myImage.setImageResource(mImageIds[position]);
        setContentView(myImage);
    }
}.show();