黑莓中的列表字段索引
我正在浏览 ListField,..当我单击所选索引时遇到问题....
我想要代码,当我单击所选索引时,它显示特定索引的所有配置文件
public class ListEmployees extends MainScreen implements ListFieldCallback
{
ListField list;
String[] items= {"Srikanth","Pradeep","Ranjith"};
public ListEmployees()
{
setTitle("List Screen");
list = new ListField();
list.setSize(3);
list.setCallback(this);
add(list);
}
使用开关盒
public void drawListRow(ListField listField, Graphics g, int index,int y, int width)
{
int a= listField.getSelectedIndex();
g.drawText(items[a], 0, y,0,50);
switch(a)
{
case 0 :
g.setColor(Color.GREEN);
Bitmap srikanthImg = Bitmap.getBitmapResource("srikanth.jpg");
if(list.getSelectedIndex()==0)
showMessage(srikanthImg,"Srikanth","1363");
else
break;
//Dialog.alert("The selected element is: " + Integer .toString ());
break;
case 1 :
g.setColor(Color.GREEN);
Bitmap PradeepImg = Bitmap.getBitmapResource("pradeep.jpg");
showMessage(PradeepImg,"Pradeep","1303");
break;
case 2 :
g.setColor(Color.GREEN);
Bitmap ranjithImg = Bitmap.getBitmapResource("ranjith.jpg");
showMessage(ranjithImg,"ranjith","1333");
break;
default :
Dialog.alert("No Information Found !!!");
}
}
private void showMessage(Bitmap map, String name1, String empId1) {
// TODO Auto-generated method stub
String data = name1 + "\n"+empId1;
UiEngine ui = Ui.getUiEngine();
Screen screen = new Dialog(Dialog.D_OK, data, Dialog.OK, map, FIELD_HCENTER);
ui.queueStatus(screen, 1, true);
I m going through ListField,..I m getting problem when i click on the selected index....
I want the code,when i click on the selected index,it is showing all the profiles for the particular index
public class ListEmployees extends MainScreen implements ListFieldCallback
{
ListField list;
String[] items= {"Srikanth","Pradeep","Ranjith"};
public ListEmployees()
{
setTitle("List Screen");
list = new ListField();
list.setSize(3);
list.setCallback(this);
add(list);
}
using switch case
public void drawListRow(ListField listField, Graphics g, int index,int y, int width)
{
int a= listField.getSelectedIndex();
g.drawText(items[a], 0, y,0,50);
switch(a)
{
case 0 :
g.setColor(Color.GREEN);
Bitmap srikanthImg = Bitmap.getBitmapResource("srikanth.jpg");
if(list.getSelectedIndex()==0)
showMessage(srikanthImg,"Srikanth","1363");
else
break;
//Dialog.alert("The selected element is: " + Integer .toString ());
break;
case 1 :
g.setColor(Color.GREEN);
Bitmap PradeepImg = Bitmap.getBitmapResource("pradeep.jpg");
showMessage(PradeepImg,"Pradeep","1303");
break;
case 2 :
g.setColor(Color.GREEN);
Bitmap ranjithImg = Bitmap.getBitmapResource("ranjith.jpg");
showMessage(ranjithImg,"ranjith","1333");
break;
default :
Dialog.alert("No Information Found !!!");
}
}
private void showMessage(Bitmap map, String name1, String empId1) {
// TODO Auto-generated method stub
String data = name1 + "\n"+empId1;
UiEngine ui = Ui.getUiEngine();
Screen screen = new Dialog(Dialog.D_OK, data, Dialog.OK, map, FIELD_HCENTER);
ui.queueStatus(screen, 1, true);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ListFieldCallback.drawListRow()
仅用于在 UI 上绘制列表项表示。看起来您正在寻找如何捕获列表上的点击事件。如果是,则重写
ListField.navigationClick()
。ListFieldCallback.drawListRow()
is just for drawing a list item representation on UI.Looks like you are looking for how to catch on-list click event. If yes, then override
ListField.navigationClick()
.