0

我需要在我的黑莓应用程序中创建一个搜索栏,就像在 android 中一样。我需要做的就是将它向右或向左滑动以增加和减少。黑莓中是否存在搜索栏,还是在黑莓中被称为滑块?

4

2 回答 2

2

Create a SliderScreen:

public class SliderScreen extends MainScreen implements FieldChangeListener
{
    private SliderField slider;
    private HorizontalFieldManager hm;

    public SliderField(){
        slider = new SliderField(
            Bitmap.getBitmapResource("slider2_thumb_normal.png"),
            Bitmap.getBitmapResource("slider2_progress_normal.png"),
            Bitmap.getBitmapResource("slider2_base_normal.png"),
            Bitmap.getBitmapResource("slider2_thumb_focused.png"),
            Bitmap.getBitmapResource("slider2_progress_focused.png"),
            Bitmap.getBitmapResource("slider2_base_focused.png"), 
            8, 4, 8, 8, FOCUSABLE);

        slider.setChangeListener(this);
        hm = new HorizontalFieldManager();
        hm.add(slider);
        setStatus(hm);
    }

    public void fieldChanged(Field field, int context) {
        try {
            if (field == slider) {
                int value = slider.getValue();
            }
        } catch (IllegalStateException e) {
            e.printStackTrace();
        } catch (NullPointerException e) {
            e.printStackTrace();
        }
    }    

and Finally get the SliderField Class and SliderImages From this BlackBerry Documents

you can get the seekbar images from BlackBerry samples

于 2012-11-14T05:33:26.020 回答
2

在 API 中有一个GaugeField,但它仅用于显示值,用户无法更改它。但是你可以使用AdvancedUiLibrarywhich 有一个SliderField. 这里的例子。

于 2012-11-13T16:57:18.397 回答