Blackberry ListField:如何添加列表行单击监听器

发布于 2024-11-19 21:30:34 字数 1150 浏览 4 评论 0原文

假设我有一个有 10 个 ListField 的 Screen 类:

Vector v_prj_title,v_prj_mgr 

// v_prj_title contains name of projects

// v_prj_mgr contains name of the project_manager of  v_prj_title sequentially.

//Vector send_vector

//ListField myList

//ListCallBack callback

//It is clear from the code that in myList, I m inserting a vector send_vector ie  callback.insert(send_vector,i), which contains 2 strings collected one from v_prj_title and other from v_prj_mgr.


for(int i=0;i<10;i++)
{
    myList.insert(i);
    t1 = v_prj_title.elementAt(i).toString();
    send_vector = new Vector(2);
    send_vector.addElement(t1);
    t2 = v_prj_mgr.elementAt(i).toString();
    send_vector.addElement(t2);
    callback.insert(send_vector,i);
}

现在我很困惑如何将 eventListener 添加到特定的 ListField,例如假设如果我单击第三个 ListField,(假设这是下面显示的数据)位图图片应该显示在第三个 ListField 和项目名称 (Project_Social_Meeting) 和项目经理 (Tom Clerk) 应插入数据库 (SQlLite)

1. a. Project_Chat_Master( project name)

   b. Vyom Ryan (project manager)

2. a. Project_Online_Gaming

   b. Vivek Roy

3. a. Project_Social_Meeting

   b. Tom Clerk  
      .
      .
      etc.....

Suppose i had a Screen class that has 10 ListField:

Vector v_prj_title,v_prj_mgr 

// v_prj_title contains name of projects

// v_prj_mgr contains name of the project_manager of  v_prj_title sequentially.

//Vector send_vector

//ListField myList

//ListCallBack callback

//It is clear from the code that in myList, I m inserting a vector send_vector ie  callback.insert(send_vector,i), which contains 2 strings collected one from v_prj_title and other from v_prj_mgr.


for(int i=0;i<10;i++)
{
    myList.insert(i);
    t1 = v_prj_title.elementAt(i).toString();
    send_vector = new Vector(2);
    send_vector.addElement(t1);
    t2 = v_prj_mgr.elementAt(i).toString();
    send_vector.addElement(t2);
    callback.insert(send_vector,i);
}

Now I'm getting confused how to add eventListener to particular ListField, e.g. suppose if I click the 3rd ListField,(suppose this is the displayed data below) a bitmap picture should be displayed in the 3rd ListField and the name of the project (Project_Social_Meeting) and project_manager (Tom Clerk) should be inserted into database (SQlLite)

1. a. Project_Chat_Master( project name)

   b. Vyom Ryan (project manager)

2. a. Project_Online_Gaming

   b. Vivek Roy

3. a. Project_Social_Meeting

   b. Tom Clerk  
      .
      .
      etc.....

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ゝ偶尔ゞ 2024-11-26 21:30:35

根据您的要求创建一个 CustomField/Manager。(可能包含图像/字符串/...)

,然后将它们添加到回调方法中,

例如:


步骤:1

//creating a custom field 
class MYListFieldItem extends Field
{
//@override
paint(graphics g)
{
g.drawbitmap(bitmap,0,0);
g.drawtext(string,bitmap.getwidth()+5<padding>,Math.min(bitmap.getHeight(),getFont().getHeight()));

//@override
layout(....)
{
setExtent(Math.min(width,bitmap.getwidth()+padding+getfont.getadvance(stringtext)),
Math.min(height,Math.min(bitmap.getHeight,getFont().getHeight())));
}
}

步骤 2:
//创建列表项

MYListFieldItem [] fields[] = new MYListFieldItem [<numOfListItems>];
for(int i=0;i<fields.size;i++)
{
_callback = new MyListFieldCallBack();
_callback.insert(fields[i],i);
}

第3步:

//set listeners
mylistFielditem[i].setchangeListener(new fieldchangeListener(){
fieldChanged(field)
{
//do your action here.
});

//TIP: if the fields are just strings,
//@override
navigationclick()
{
if(status == keypadlistener.status_fourway)
{
MYListFieldItem  fld = (ListField)getLiefFieldwithFocus();
//do your coding 

}
}

create a CustomField/Manager depending on your requirement.(which may contain images/strings/...)

then add them to the callback method

Ex:


step:1

//creating a custom field 
class MYListFieldItem extends Field
{
//@override
paint(graphics g)
{
g.drawbitmap(bitmap,0,0);
g.drawtext(string,bitmap.getwidth()+5<padding>,Math.min(bitmap.getHeight(),getFont().getHeight()));

//@override
layout(....)
{
setExtent(Math.min(width,bitmap.getwidth()+padding+getfont.getadvance(stringtext)),
Math.min(height,Math.min(bitmap.getHeight,getFont().getHeight())));
}
}

step-2:
//create list items

MYListFieldItem [] fields[] = new MYListFieldItem [<numOfListItems>];
for(int i=0;i<fields.size;i++)
{
_callback = new MyListFieldCallBack();
_callback.insert(fields[i],i);
}

step-3:

//set listeners
mylistFielditem[i].setchangeListener(new fieldchangeListener(){
fieldChanged(field)
{
//do your action here.
});

//TIP: if the fields are just strings,
//@override
navigationclick()
{
if(status == keypadlistener.status_fourway)
{
MYListFieldItem  fld = (ListField)getLiefFieldwithFocus();
//do your coding 

}
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文