Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
Posts: 10
Registered: ‎01-16-2013
My Device: BB7 and BB10
My Carrier: Airtel

ObjectChoiceField/list on click of image

Hello folks,

 

I am developing an app on BB7.1 on java.

 

I am trying to get a dropdown list on click of image.

 

I even went through the post:

http://supportforums.blackberry.com/t5/Java-Development/ObjectChoiceField-on-Image-Click/m-p/449781/...

 

 

This is not working for me.

 

 

My Code;

 

Bitmap bitmapImage = Bitmap.getBitmapResource("system-star-icon.png");
        BitmapField fieldDemo = new BitmapField(bitmapImage);
        fieldDemo.setMargin(2, 5, 5, 0);

 

        final ObjectChoiceField starSort=new ObjectChoiceField("",starRating){
        protected void fieldChangeNotify(int context) {
        // TODO Auto-generated method stub
        
                int selectedIndex=getSelectedIndex();
                if(selectedIndex==1){
                Collections.insertionSort(hoteldetails, new StarHigherComparator());
//                HotelListingLoop.SELECTED_DAY=1;
                HotelListingLoop hotelchange=new HotelListingLoop(hoteldetails, HotelListingScreen.this);
                vfm.replace(vfm.getField(0),hotelchange);
              
                
                }
                else if(selectedIndex==2){
                    Collections.insertionSort(hoteldetails, new StarComparator());
                    HotelListingLoop hotelchange=new HotelListingLoop(hoteldetails, HotelListingScreen.this);
                    vfm.replace(vfm.getField(0),hotelchange);
                }
                super.fieldChangeNotify(context);

        }    
        
        protected void paint(Graphics graphics) {
                graphics.setColor(Color.WHITE);
                graphics.setFont(DivumConstants.fontMedium);
                super.paint(graphics);
            }
            protected void layout(int width, int height) {
                // TODO Auto-generated method stub
                super.layout(Display.getWidth()/4, getHeight());
                super.setExtent(Display.getWidth()/4,getHeight());
            }
        };

 

fieldDemo = new BitmapField(bitmapImage, ButtonField.CONSUME_CLICK
                | ButtonField.FOCUSABLE) {
            protected boolean navigationClick(int status, int time) {
                // Dialog.alert("refresh!");
               starSort.getContextMenu();
                return true;

            }
        };

suprtField.add(fieldDemo);

 

 

 

Can somebody please suggest me how to achieve this. I am missing something out here.

 

Basically on click of image i need a list to be displayed.

 

 

Thanks in advance.