2013-02-08 31 views
0
Intent intent = new Intent(); 
intent.setType("image/*"); 
intent.setAction(Intent.ACTION_GET_CONTENT); 
startActivityForResult(Intent.createChooser(intent, "Select Picture"),1); 

以上要帶我們去畫廊應用程序,它是存在於我們的設備,所以我們會得到圖庫屏幕佔據我們device.But的全部顯示我想要顯示在一個小的佈局,畫廊的應用程序視圖(就像我在下圖中顯示的那樣,而不是EditText,Buttons,我想在這個小布局中獲得我的設備畫廊屏幕)。因此,我可以讓用戶感覺他沒有移出應用程序。如何在android的自定義視圖中顯示移動圖庫頁面?

我在其中一個IPAD應用程序(HelloAlbums)中看到了這個。

是否有可能在Android中實現這一點?

我使用上面的代碼來調用手機庫應用程序。

但我想在自定義視圖中顯示圖庫頁面。 enter image description here

假設像我在下面使用的視圖。

我該如何做到這一點?

請建議

感謝

回答

1

請去這個link

和修改imageadapter類由

public View getView(int position, View convertView, ViewGroup parent) { 
    ImageView i = new ImageView(mContext); 

    i.setImageResource(mImageIds[position]); 
    i.setLayoutParams(new Gallery.LayoutParams(150, 100));//make change of this size 
    i.setScaleType(ImageView.ScaleType.FIT_XY); 
    i.setBackgroundResource(mGalleryItemBackground); 

    return i; 
} 

只需更改layoutParams的高度和寬度。

+0

我在問如何顯示全屏顯示的畫廊頁面,所以我想在自定義視圖中顯示,我在上面提到的圖片中。 – user1891910

4

試試這個

public void ChoosePicture(View v) { 
    Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); 
    photoPickerIntent.setType("image/*"); 
    startActivityForResult(photoPickerIntent, 1); 
} 

public void onActivityResult(int requestCode, int resultCode, Intent data) { 
    super.onActivityResult(requestCode, resultCode, data); 
    switch (requestCode) { 
    case 1: 
    { 
     if (resultCode == RESULT_OK) 
     { 
     Uri photoUri = data.getData(); 
     if (photoUri != null) 
     { 
     try { 
       String[] filePathColumn = {MediaStore.Images.Media.DATA}; 
       Cursor cursor = getContentResolver().query(photoUri, filePathColumn, null, null, null); 
       cursor.moveToFirst(); 
       int columnIndex = cursor.getColumnIndex(filePathColumn[0]); 
       String filePath = cursor.getString(columnIndex); 
       cursor.close(); 
       bMap_image = BitmapFactory.decodeFile(filePath); 
       ImageView img = (ImageView) findViewById(R.id.gallery1); 
       img.setImageBitmap(bMap_image); 


    }catch(Exception e) 
     {} 
     } 
    }// resultCode 
    }// case 1 
    }// switch, request code 
} 
+0

我有這段代碼,在此之前我想在自定義視圖中顯示圖庫頁面。 – user1891910

相關問題