Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/375.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何将图像添加到栅格视图,并将单击功能添加到这些图像?_Java_Blackberry_Java Me - Fatal编程技术网

Java 如何将图像添加到栅格视图,并将单击功能添加到这些图像?

Java 如何将图像添加到栅格视图,并将单击功能添加到这些图像?,java,blackberry,java-me,Java,Blackberry,Java Me,我可以创建一个简单的gridview,现在我想添加图像并为这些图像添加单击功能,请帮助我完成此操作。试试这个- public final class gridFieldDemoScreen extends MainScreen { LabelField one, two, three, four, five, six; public gridFieldDemoScreen() { setTitle("gridFieldDemo");

我可以创建一个简单的gridview,现在我想添加图像并为这些图像添加单击功能,请帮助我完成此操作。

试试这个-

public final class gridFieldDemoScreen extends MainScreen
{
    LabelField one, two, three, four, five, six;
    public gridFieldDemoScreen()
    {
        setTitle("gridFieldDemo");   
        GridFieldManager grid = new GridFieldManager(2, 3, 0);
        one = new LabelField("ONE");
        grid.insert(one, 0);
        two = new LabelField("TWO");
        grid.insert(two , 1);
        three = new LabelField("THREE");
        grid.insert(three, 2);
        four = new LabelField("FOUR");
        grid.insert(four, 3);
        five = new LabelField("FIVE");
        grid.insert(five, 4);
        six = new LabelField("SIX");
        grid.insert(six, 5);
        grid.setColumnPadding(20);
        grid.setRowPadding(20);
        add(grid);
    }
}

对于刚刚否决我的问题的人,请你在这里发表评论,这样我就可以知道我的问题需要改进什么,我也可以改进它。给我一个你否决这一项的合理理由-世界跆拳道联盟
GridFieldManager grid = new GridFieldManager(2,2,0); 
EncodedImage g1 = EncodedImage.getEncodedImageResource("image1.png");
EncodedImage g2 = EncodedImage.getEncodedImageResource("image2.png");
EncodedImage g3 = EncodedImage.getEncodedImageResource("image3.png");
EncodedImage g4 = EncodedImage.getEncodedImageResource("image4.png");

grid.add(new BitmapField(g1.getBitmap(),FOCUSABLE){
          protected boolean navigationClick(int status, int time){
                          //here your can add your code.
                return true;
            }

    });
grid.add(new BitmapField(g2.getBitmap(),FOCUSABLE){
              protected boolean navigationClick(int status, int time){
                              //here your can add your code.
                    return true;
                }

        });
grid.add(new BitmapField(g3.getBitmap(),FOCUSABLE){
              protected boolean navigationClick(int status, int time){
                              //here your can add your code.
                    return true;
                }

        });
grid.add(new BitmapField(g4.getBitmap(),FOCUSABLE){
              protected boolean navigationClick(int status, int time){
                              //here your can add your code.
                    return true;
                }

        });



 add(grid );