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
Blackberry 是否可以将2个参数传递给listfieldcallback类?_Blackberry - Fatal编程技术网

Blackberry 是否可以将2个参数传递给listfieldcallback类?

Blackberry 是否可以将2个参数传递给listfieldcallback类?,blackberry,Blackberry,我是黑莓开发的新手。我想知道有没有其他方法来解决我的申请。我开发了一个简单的计算器应用程序 value1 : 6 value2 : 3 Calculate + : 9 - : 3 * : 18 / : 2 其中value1和value2是两个编辑字段,calculate是ButonField。在我的代码中,我编写了一个字符串数组{“+”、“-”、“*”、“/”},用于传递给实现ListFieldCallBack的类 它的编码如下 for(int i = 0; i<arr

我是黑莓开发的新手。我想知道有没有其他方法来解决我的申请。我开发了一个简单的计算器应用程序

value1 : 6
value2 : 3
Calculate

+  :  9
-  :  3
*  :  18
/  :  2
其中value1和value2是两个编辑字段,calculate是ButonField。在我的代码中,我编写了一个字符串数组{“+”、“-”、“*”、“/”},用于传递给实现ListFieldCallBack的类

它的编码如下

for(int i = 0; i<array.length;i++)
        {
            mylist.insert(i);
                    //calculated the result 
            myCallBack.insert(array[i]+"#"+result );
        }

for(inti=0;i好吧,这与blackberry无关。这与我们在OOP开发中使用的习惯用法有关

由于列表项表示两条信息(一个数学运算和一个结果),因此需要为列表项创建一个模型来封装这两条信息:

public class ListItem {

    public final String operation;
    public final String result;

    public ListItem(String operation, String result) {
        this.operation = operation;
        this.result    = result;
    }
}
然后在
ListFieldCallBack
内部应该有一个
Vector
ListItem
实例。因此,当调用
myCallBack.insert(newlistItem(operation,result));
时,它会将列表项添加到该向量中

当您在
drawListRow(ListField ListField,Graphics Graphics,int index,int y,int width)
中时,您首先通过其索引获取列表项,然后您可以轻松获取列表项状态,而无需拆分字符串或执行任何其他脏操作。因此,代码变得干净且面向对象:

ListItem li = // get ListItem by index

li.operation; // operation
li.result;    // result

嗯,这与黑莓无关。这与我们在OOP开发中使用的习惯用法有关

由于列表项表示两条信息(一个数学运算和一个结果),因此需要为列表项创建一个模型来封装这两条信息:

public class ListItem {

    public final String operation;
    public final String result;

    public ListItem(String operation, String result) {
        this.operation = operation;
        this.result    = result;
    }
}
然后在
ListFieldCallBack
内部应该有一个
Vector
ListItem
实例。因此,当调用
myCallBack.insert(newlistItem(operation,result));
时,它会将列表项添加到该向量中

当您在
drawListRow(ListField ListField,Graphics Graphics,int index,int y,int width)
中时,您首先通过其索引获取列表项,然后您可以轻松获取列表项状态,而无需拆分字符串或执行任何其他脏操作。因此,代码变得干净且面向对象:

ListItem li = // get ListItem by index

li.operation; // operation
li.result;    // result

@阿希米德:-谢谢你,阿希米德。实际上我已经试过了。但在ListFieldCallBack的插入函数中,我犯了错误。你的指导真的帮了我。谢谢alot@Arhimed:-谢谢你,阿希米德。实际上我已经试过了。但是在ListFieldCallBack上的插入函数中,我犯了错误。你的指导真的帮助了我。非常感谢