开发者

how to create folder?

Merged with How to create folders in my gallery app?.

Hi I have created one gallery. It's working fine. The gallery displays images in separate images in this gallery, but I need all pictures in one folder. If I click the folder then display separate images. Then I click that image I need full screen. Please tell me which method it's match of this coding. Please tell me. Example: car folder, camera folder, actress folder. I am not familiar with java coding.

This is my current working coding:

 package ImageViewExample.ImageViewExample;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Gallery;
//import android.widget.GridView;
import android.widget.ImageView;
import android.widget.AdapterView.OnItemClickListener;

public class ImageViewExample extends Activity {
  /** Called when the activity is first created. */
  private Cursor imagecursor, actualimagecursor;
  private int image_column_index, actual_image_column_index;
  Gallery imagegrid;
  private int count;
  @Override
  public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        init_phone_image_grid();
  }
  private void init_phone_image_grid() {
        String[] img = { MediaStore.Images.Thumbnails._ID };
        imagecursor = managedQuery(
  MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, img, null,
  null, MediaStore.Images.Thumbnails.IMAGE_ID + "");
        image_column_index = imagecursor
  .getColumnIndexOrThrow(MediaStore.Images.Thumbnails._ID);
        count = imagecursor.getCount();
        imagegrid = (Gallery) findViewById(R.id.PhoneImageGrid);
        imagegrid.setAdapter(new ImageAdapter(getApplicationContext()));
        imagegrid.setOnItemClickListener(new OnItemClickListener() {
              public void onItemClick(AdapterView parent, View v,
   int position, long id) {
                    System.gc();
                    String[] proj = { MediaStore.Images.Media.DATA };
                    actualimagecursor = managedQuery(
    MediaStore.Images.Media.EXTERNAL_CONTENT_URI, proj,
    null, null, null);
                    actual_image_column_index = actualimagecursor
    .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
                    actualimagecursor.moveToPosition(position);
                    String i = actualimagecursor.getString(actual_image_column_index);
                    System.gc();
                    Intent intent = new Intent(getApplicationContext(),     
     ViewImage.class);
                    intent.putExtra("filename", i);
                    startActivity(intent);
              }
        });
       }


  public class ImageAdapter extends BaseAdapter {
        private             Context mContext;
        public ImageAdapter(Context c) {
              mContext = c;
        }
        public int getCount() {
              return count;
        }
        public Object getItem(int position) {
              return position;
        }
        public long getItemId(int position) {
              return position;
        }
        public View getView(int position,View convertView,ViewGroup parent) {
              System.gc();
              ImageView i = new Image开发者_如何转开发View(mContext.getApplicationContext());
              if (convertView == null) {
                    imagecursor.moveToPosition(position);
                    int id = imagecursor.getInt(image_column_index);
                    i.setImageURI(Uri.withAppendedPath(
      MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, ""
     + id));
                    i.setScaleType(ImageView.ScaleType.CENTER_CROP);
                    i.setLayoutParams(new Gallery.LayoutParams(110,110));
              }
              else {
                    i = (ImageView) convertView;
              }
              return i;
        }
    }
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜