如何交换上查看位图图像中的android? [英] How to swap the bitmap images on View in android?

查看:164
本文介绍了如何交换上查看位图图像中的android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的小应用程序显示工作气泡在Android screen.I图像都显示所有的泡沫从资源directory.I图像已实现code。在视图类如下:

I am working with small application for display bubbles images on android screen.I have displayed all bubbles images from resource directory.I have implemented code as follows in view class.

的OnDraw方法:

    @Override
protected void onDraw(Canvas canvas) 
{
    super.dispatchDraw(canvas);


    drawImages(canvas);

}

我已经实现drawImages()方法如下:

I have implemented drawImages() method as follows:

BitmapFactory.Options opts = new BitmapFactory.Options();   
private void drawImages(Canvas canvas) 
{

        for(int i = 0; i<MAX_ROWS; i++){
            for(int j=0; j<MAX_COLS; j++)
            {
                bmp = BitmapFactory.decodeResource(mContext.getResources(), items[i][j],opts);
                    canvas.drawBitmap(bmp,j*bmp.getWidth()+j*2,i*bmp.getHeight()+i*2,mBitmapPaint);
            }
        }

}

通过使用上面的方法我已经从项目得出的图像[I] [J]。 我已经实现了初始化()覆盖方法如下:

By using the above method i have drawn images from items[i][j]. I have implemented the initialize() override method as follows:

 @Override
protected void initialize() 
{

    for(int i=0;i<MAX_ROWS;i++)
        for(int j=0;j<MAX_COLS;j++)
        {
            items[i][j] = ImagesStore.ImageList.get(list_Indx);
            list_Indx++;
            if(list_Indx == ImagesStore.ImageList.size())
                list_Indx = 0;

    }
    opts.inSampleSize = 4;
    width  = getWidth();
    height = getHeight();

}

通过使用上述codeI已经显示所有的泡泡图片我模拟器的屏幕上。

By using above code i have displayed all the bubble images on my emulator screen.

在这里,我想掉它选择两个气泡通过同时用户的泡沫。

Here i would like to swap the bubbles which selects two bubbles by the user simultaneously.

我已经实现的onTouchEvent方法检查的位图图像项目的位置在屏幕上,如下所示:

I have implemented onTouchEvent method for check the bitmap image item position on screen as follows:

               int x = 0;
               int y = 0;
               int tx = 0, ty = 0;   
           @Override
public boolean onTouchEvent(MotionEvent event) 
{

     tx = (int)event.getX();
     ty = (int)event.getY();
    int position;

        x=tx;
        y=ty;

        row = (y) / bmp.getHeight();
        col = x / bmp.getWidth();

        position=row*MAX_COLS+(col+1);

        Log.v("row", "=====>"+row);

        Log.v("col", "=====>"+col);

        Log.v("position", "=====>"+position);

    count++;

    if(count%4==0)
    {

    Log.v("count", "=====>"+count);


    //I would like to implement swap code here



    }   
    return true;
}

从上面的code我怎么能掉(除改变图像)的位图图像执行情况的onTouchEvent()

From the above code How can i swap(inter change the images) bitmap images implementation at onTouchEvent()

请任何机构可以帮助我...........

Please any body help me..............

推荐答案

请确定你所渴望的功能。

Please define the functionality that you desire as..

在这里,我想掉它选择两个气泡通过同时用户的泡沫。

"Here i would like to swap the bubbles which selects two bubbles by the user simultaneously."

不是一个完整的句子。

这篇关于如何交换上查看位图图像中的android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆