简体   繁体   English

黑莓风暴和火炬中的listfield

[英]listfield in blackberry storm and torch

I have listfield which contains several rows. 我有包含几行的列表字段。 It is working fine when i am using in blackberry torch(I can scroll the listfield and can select(click) any row). 当我在黑莓手电筒中使用时,它工作正常(我可以滚动列表字段并可以选择(单击)任何行)。 But the same application when i am using for blackberry storm 9500 I can not scroll because as soon as i am trying to scroll the row is getting selected(click).please tell me the reason why it is happening or the way to use listfield in storm 但同样的应用程序,当我用于黑莓风暴9500我无法滚动,因为一旦我尝试滚动行被选中(点击)。请告诉我它发生的原因或使用列表字段的方式风暴

thank you 谢谢

My lisfield class is 我的利斯菲尔德班是

import net.rim.device.api.system.Bitmap;
import net.rim.device.api.system.Display;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.XYRect;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.ListField;
import net.rim.device.api.ui.component.ListFieldCallback;

  public class SpeakersList implements ListFieldCallback
{
    private String[] products;
    private int rgb=Color.BLACK;
    Bitmap arraow;
    Bitmap placeholder;
    Bitmap holder[];
    int i=0;
    ImageLoad load;
    public Bitmap _bmap;
    ListField listField;
    TaskWorker taskWorker;
public SpeakersList(String[] products)
{
    this.products=products;
    arraow= Bitmap.getBitmapResource("arrow.png");
    DynamicImages images=new DynamicImages();
    placeholder=Bitmap.getBitmapResource(images.defaultimage);
    holder=new Bitmap[QandAScreen.imglist.length];
    taskWorker = new TaskWorker();
    taskWorker.addTask(new ImageDowload());
}

public void drawListRow(ListField listField, Graphics graphics, int index,
        int y, int width)
{
    this.listField=listField;
    final String text=(String) get(listField, index);
    if (graphics.isDrawingStyleSet(Graphics.DRAWSTYLE_FOCUS))
    {
    if(holder[index]==null)
    {
    holder[index]=placeholder;
    }
    graphics.setColor(0xC0C0C0);
    graphics.fillRect(0,y+0,480,59);
    graphics.setColor(rgb);
    graphics.setFont(Utility.getBigFont(15));
    graphics.drawBitmap(3,y+7,placeholder.getWidth(), placeholder.getHeight(),holder[index], 0, 0);
    graphics.drawText(text,70,y+20);  
    if(Display.getWidth()==480){
    graphics.drawBitmap(460,y+20,arraow.getWidth(), arraow.getHeight(),arraow, 0, 0);
    }
    else if(Display.getWidth()==360)
    {
        graphics.drawBitmap(330,y+20,arraow.getWidth(), arraow.getHeight(),arraow, 0, 0);
    }
    else
    {
    graphics.drawBitmap(300,y+20,arraow.getWidth(), arraow.getHeight(),arraow, 0, 0);
    }
    graphics.drawLine(0, y+59, Display.getWidth(), y+59);
    }
    else
    {
        if(holder[index]==null)
        {
        holder[index]=placeholder;
        }
        graphics.setColor(rgb);
        graphics.setFont(Utility.getBigFont(15));
        graphics.drawBitmap(3,y+7,placeholder.getWidth(), placeholder.getHeight(),holder[index], 0, 0);
        graphics.drawText(text,70,y+20);  
        if(Display.getWidth()==480){
            graphics.drawBitmap(460,y+20,arraow.getWidth(), arraow.getHeight(),arraow, 0, 0);
            }
        else if(Display.getWidth()==360)
        {
            graphics.drawBitmap(330,y+20,arraow.getWidth(), arraow.getHeight(),arraow, 0, 0);
        }
            else
            {
            graphics.drawBitmap(300,y+20,arraow.getWidth(), arraow.getHeight(),arraow, 0, 0);
            }
        graphics.drawLine(0, y+59, Display.getWidth(), y+59);
    }
}
public Object get(ListField listField, int index)
{
    return products[index];
}

public int getPreferredWidth(ListField listField)
{
    return Display.getWidth()+10;
}
public int indexOfList(ListField listField, String prefix, int start)
{
    return -1;
}

class ImageDowload extends Task
{
    void doTask()
    {


   for(;i<QandAScreen.imglist.length;i++)
   {
        String imgpath=QandAScreen.imglist[i];
         if(imgpath==null || imgpath.length()==0)
         {
          continue;
         }
        load=new  ImageLoad(QandAScreen.imglist[i]+Const.getExtra());
        if(load.getData()!=null)
        {
            UiApplication.getUiApplication().invokeLater(new Runnable() 
            {
                public void run()
                {

                    _bmap=load.getBitmap(40,40);
                    listField.invalidate(i-1);
                    holder[i-1]=_bmap;


               }
            });



        }
   }

    }
}
}

Are you testing with the simulators or real devices? 您正在使用模拟器或真实设备进行测试吗? If my memory serves, the 9500 Storm uses the SureClick -display, where the display actually has a small microswitch underneath it, so it can detect touch and clicking (pressing the display) as separate actions. 如果需要我帮忙的话,9500 Storm会使用SureClick-显示屏,在该显示屏的下面实际上有一个微型开关,因此它可以将触摸和点击(按下显示屏)作为单独的动作来检测。 In the simulator, you need to use right mouse button to simulate touch and left to simulate click (or was it the other way around?). 在模拟器中,您需要使用鼠标右键来模拟触摸,然后左键来模拟点击(或者是相反的方式?)。 Torch (9800) hasn't got the SureClick-thingamabob, so the list can be scrolled with both right and left mouse buttons in the simulator (although they did have some distinction, other worked as touch and other sends continuous 'taps' to the screen or something). Torch(9800)尚未安装SureClick-thingamabob,因此可以在模拟器中使用左右鼠标按钮来滚动列表(尽管它们确实有所区别,但其他功能可以通过触摸来实现,而其他功能可以将连续的“敲击”发送给模拟器​​)屏幕或东西)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM