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 ) 和 project_manager (Tom Clerk) 应该插入到数据库 (SQLlite)

1.一个。Project_Chat_Master(项目名称)

   湾。Vyom Ryan(项目经理)

2.一个。项目_在线_游戏

   湾。维维克·罗伊

3.一个。项目_社交_会议

   湾。汤姆文员  
      .
      .
      ETC.....
4

1 回答 1

1

根据您的要求创建一个 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())));
}
}

step-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 

}
}
于 2012-01-03T12:07:36.313 回答