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
Developer
Posts: 15
Registered: ‎09-03-2009
My Device: Not Specified

Problem in Storm Tab Bar functionality implementation

Hello All,

       
    I am trying to build an application for storm in which one screen is having ListField with several other elements.

Below the list I have added Tab Bar with several buttons with different functionalities.

When clicking on each list index it will be redirecting to different screen with respect to the pressed list index.

I implemented the code for Tab Bar which is given in following link

(http://supportforums.blackberry.com/t5/Java-Development/Shortcut-Bar/m-p/394782#M76724)



TabBarTest() // constructor
{
    this.vm = new VerticalFieldManager(Manager.VERTICAL_SCROLL|Manager.VERTICAL_SCROLLBAR|Manager.USE_ALL_HEIGHT)

    this.vm.add(this.receivedMsgList);   // Adding list components

    this.rowManager = new HorizontalFieldManager()
        {
            public void sublayout(int width, int height)
            {
                super.sublayout(Display.getWidth(),Bitmap.getBitmapResource("back2.png").getHeight());
                setExtent(Display.getWidth(),Bitmap.getBitmapResource("back2.png").getHeight());
            }
            public void paint(Graphics g)
            {
                     g.setBackgroundColor(Color.BLACK);
                     g.fillRect(0,0,Display.getWidth(),getHeight());
                     g.clear();
                     super.paint(g);
            }
     
        };
    back_1 = new BitmapField(Bitmap.getBitmapResource("back2.png"),BitmapField.FOCUSABLE)
    {
            protected boolean invokeAction(int action)
            {
                return true;
             }
           
            protected void onUnfocus()
            {
                   rowManager.invalidate();
                   super.onUnfocus();
            }
    };

    // similarly 3 other buttons

    rowManager.add(back_1);
    back_1.setFocusListener((FocusChangeListener) this);

    // added listener for other buttons

    setStatus(rowManager);

    this.add(vm);
        
} //constructor end



public void focusChanged(Field field,int eventType)
{
        
        if (eventType == TouchGesture.TAP) 
        {
            System.out.println("eventType == FOCUS_CHANGED)");

            BitmapField bttnField1 = (BitmapField) field;

            if(field instanceof BitmapField)
            {
                
                if(field.getIndex() == 0)
                {
                    // BUTTON FUCTION -1
                }
                else if(field.getIndex() == 2)

                {

                        // BUTTON FUCTION -2

                }

                else if(field.getIndex() == 3)
                {
                    scroll(Manager.UPWARD);
                }

                else if(field.getIndex() == 4)
                {
                    scroll(Manager.DOWNWARD);
                }

            }
            
        }
}

//implementing touch event to get the index of pressed list index

protected boolean touchEvent(TouchEvent message)
    {
         if (message.getEvent() == TouchEvent.GESTURE)
         {
              // Check if a list item is selected.
             TouchGesture gesture = message.getGesture();
             int gestureCode = gesture.getEvent();
         
             if (gestureCode == TouchGesture.TAP)
             {
                 if (receivedMsgList.getSelectedIndex() > -1)
                 {
                      setTouchedIndex(receivedMsgList.getSelectedIndex());
                      return true;
                 }
                
                 invalidate();            
             }
         }
         return super.touchEvent(message);
    }

public int getTouchedIndex()
{
        return touchedIndex;
}

public void setTouchedIndex(int touchedIndex)
{
        this.touchedIndex = touchedIndex;
}
public void drawListRow(ListField listField, Graphics graphics, int index,int y, int width)
{

    // implemented

}

public Object get(ListField listField, int index)
{

  // implemented

}

public int indexOfList(ListField listField, String prefix, int start)
{

   // implemented

}

 

Now what happens is when pressing on Tab buttons for moving UP and down ,rather than screen moving up or down

 

,the functions assigned for the list according to the index retrieved is done.

Rest of all the functions are done correctly.

What is to be changed in the code for correcting this ...

Please Help me out

Highlighted
Developer
Posts: 15
Registered: ‎09-03-2009
My Device: Not Specified

Re: Problem in Storm Tab Bar functionality implementation

Hello All,

 

 

                Anybody have any idea to solve this issue?Smiley Sad

 

 

 

Regards

 

harry