Android Grid Image Adapter跳过帧

时间:2014-06-21 12:26:57

标签: java android baseadapter frames skip

Hey Guys我正在开发一个简单的应用程序,它在GridView中显示图像并在点击时全屏显示问题是它正在跳帧。这是代码..检查一下。

MainActivity

public class MainActivity extends Activity {

    GridView gridView;
    private String[] web = { "String1", "String2", "String3",
            "String4", "String5", "String6" };

    private int[] ImageId = { R.drawable.image1, R.drawable.image2,
            R.drawable.image3, R.drawable.image4, R.drawable.5,
            R.drawable.image6 };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_main);

        gridView = (GridView) findViewById(R.id.gridView1);
        gridView.setAdapter(new GalleryImageAdapter(this, web, ImageId));

        gridView.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View v, int position,
                    long id) {
                Intent intentFull = new Intent(getApplicationContext(), FullScreenImage.class);
                intentFull.putExtra("id", position);
                startActivity(intentFull);

            }
        });

    }
}

GalleryImageAdapter.class

public class GalleryImageAdapter extends BaseAdapter {

    private Context mContext;

    public String[] web = { "String1", "String2", "String3",
            "String4", "String5", "String6" };

    public int[] ImageId = { R.drawable.image1, R.drawable.image2,
            R.drawable.image3, R.drawable.image4, R.drawable.5,
            R.drawable.image6 };

    public GalleryImageAdapter(Context context, String[] web, int[] ImageId) {
        mContext = context;
    }

    @Override
    public int getCount() {
        return web.length;
    }

    @Override
    public Object getItem(int position) {
        return ImageId[position];
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View grid;
        ImageView imageView = null;
        LayoutInflater inflater = (LayoutInflater) mContext
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        if (convertView == null) {
            grid = new View(mContext);
            grid = inflater.inflate(R.layout.grid_single_item, null);
            TextView textView = (TextView) grid.findViewById(R.id.textDua);
            imageView = (ImageView) grid.findViewById(R.id.imageDua);
            textView.setText(web[position]);
            imageView.setImageResource(ImageId[position]);
        } else {
            grid = (View) convertView;
        }

        return grid;
    }
}

图像在网格跳帧中显示的主要布局,但是当我点击singleItem时,即单个图像(当然)工作正常......

谢谢!

0 个答案:

没有答案