English 中文(简体)
甲型六氯环己烷
原标题:Android ImageAdapter
  • 时间:2012-01-11 15:11:07
  •  标签:
  • android

那么,我会利用一点帮助了解扩大基达普特的图像。 上个月,在我手头的屋顶上,我一米一直在工作,被 st。 我的项目很少。 它跟踪车辆。 对于任何车辆,用户可以照相带照相机照相照相。 这部分内容行之有效。 我可以带照片,并在内部储存中保存。 然后,我把这条道路留给了一张板块。 我的数据库有一张图象(id)外面1,一部汽车(v_id)面1,还有一条通往图像(i_image)的道路(i_image)。 我核实了图像档案,数据库的输入正得到正确保存。 现在到困难部分:在GridView中显示图像。 图Adapter 试图效仿的i m 就是这样:

    public class ImageAdapter extends BaseAdapter {
    private LayoutInflater mInflater;
    public ArrayList<ImageItem> images = new ArrayList<ImageItem>();

    public ImageAdapter() {
        mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    public void initialize() {
        images.clear();
        final String[] columns = { MediaStore.Images.Thumbnails._ID };
        final String orderBy = MediaStore.Images.Media._ID;
        Cursor imagecursor = null;
        try {
            ContextWrapper context = MorePhotoTesting.this;
            imagecursor = context.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns, null, null, orderBy);
        } catch(Exception e) {
            e.printStackTrace();
        }

        if(imagecursor != null){
            int image_column_index = imagecursor.getColumnIndex(MediaStore.Images.Media._ID);
            int count = imagecursor.getCount();
            for (int i = 0; i < count; i++) {
                imagecursor.moveToPosition(i);
                int id = imagecursor.getInt(image_column_index);
                ImageItem imageItem = new ImageItem();
                imageItem.id = id;
                lastId = id;
                imageItem.img = MediaStore.Images.Thumbnails.getThumbnail(getApplicationContext().getContentResolver(), id,
                        MediaStore.Images.Thumbnails.MICRO_KIND, null);
                images.add(imageItem);
            }
            imagecursor.close();

        }
        notifyDataSetChanged();
    }

我相信,一旦我理解(......)的初衷。 我可以宣布意见。 显然,这个例子正在使用媒体仓库,在那里我将使用内部储存。 我马上消失了,我的研究已经空洞。 我看不到如何用我的数据库代码来取代媒体储存。 如果任何人能够把我引向将伟大的正确方向! 举例说:

    class ImageItem {
    boolean selection;
    int id;
    Bitmap img;
}

主要活动的呼吁类似:

    imageAdapter = new ImageAdapter();
    imageAdapter.initialize();
    imagegrid = (GridView) findViewById(R.id.PhoneImageGrid);
    imagegrid.setAdapter(imageAdapter);

我道歉,但这是我处理这些特点的第一个项目。

最佳回答

我并不完全相信这里有具体问题,但我在你的法典中注意到:

imagecursor = context.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns, null, null, orderBy);

由于你正在内部电话储存中储存你的图像,你或许应当使用<代码>。 MediaStore.Images.Media.INTERNAL_CONTENT_URI, 至少。

我还注意到你重新使用<代码>getThumbnail()。 这只能用纸张上储存的内容。

问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签