0

我在 github 中下载了 page curl 项目,以便使用 gridview 将其应用到我的项目中。一旦我在gridview中单击图像,它将转到另一个活动,其中有图像数组,我将使用bundle将id从我的gridview传递给我的fullview活动。我想使用页面卷曲动画在全视图中的图像之间滑动,这样用户就不必回到 gridview 来查看另一个图像。但我不能将整数传递给 ARRAYLIST。以下是片段:

这是我在此链接中的 pagecurl 适配器:http: //pastebin.com/JCq2YD6r

我的网格视图的基本适配器在这里:

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Log;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.Toast;

public class ImageAdapter extends BaseAdapter {
    private Context mContext;

    public Integer[] mThumbIds = {
            R.drawable.r01,R.drawable.r02
            ,R.drawable.r03,R.drawable.r04,
            R.drawable.r05,R.drawable.r06,
            R.drawable.r07,R.drawable.r08,
            R.drawable.r09,R.drawable.r10,
            R.drawable.r11,R.drawable.r12



    };
    public ImageAdapter(Context c){
        mContext = c;
    }
    public int getCount() {
        // TODO Auto-generated method stub
        return  mThumbIds.length;
    }

    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return mThumbIds[position];
    }

    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return 0;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        ImageView imageView;

        SharedPreferences app_preferences = 
                PreferenceManager.getDefaultSharedPreferences(MainTab.current_act);
        int dpw = app_preferences.getInt("dpiw", 0);

        Log.i("IMmmm" , "" + dpw);
//      if (convertView == null) {  
         imageView = new ImageView(mContext);
         imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        imageView.setImageResource(mThumbIds[position]);


//        int width = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 150, parent.getResources().getDisplayMetrics());
//        int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 175, parent.getResources().getDisplayMetrics());

        final float scale = parent.getResources().getDisplayMetrics().density;
        int width = (int) (100 * scale + 0.5f);
        int height = (int) (150 * scale + 0.5f);
        Log.i("with h " , ""+width + "  " + height + "   scale   " + scale );

        imageView.setLayoutParams(new GridView.LayoutParams(width, height));
        //}

//      } else {
//          imageView = (ImageView) convertView;
//        }

        return imageView;
    }


}

这是我想在页面卷曲适配器中更改的部分

    // Create pages
    mPages = new ArrayList<Bitmap>();
    mPages.add(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher));
    mPages.add(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher));

如何将整数数组传递给这个数组列表是位图?顺便说一句,你怎么称呼它?数组列表?那是位图的arraylist吗?:)

4

1 回答 1

0

检查这个例子:http ://devappandroid.com/android-beginner/page-curlturn-effect-android

// Create pages
    mPages = new ArrayList<Bitmap>();
    mPages.add(BitmapFactory.decodeResource(getResources(),
            R.drawable.page1));
    mPages.add(BitmapFactory.decodeResource(getResources(),
            R.drawable.page2));
    mPages.add(BitmapFactory.decodeResource(getResources(),
            R.drawable.page3));
    mPages.add(BitmapFactory.decodeResource(getResources(),
            R.drawable.page4));
于 2012-11-28T17:09:36.577 回答