drawListRow only call on focused rows (Blackberry 4.5) - blackberry

It always draw all focus elements , but it doesnt refresh the others until listfield is scrolled. That's only a problem in Blackberry 4.5 , 5.0 is ok.
I have tried to do the next before draw anything intoe the row :
public void drawListRow(ListField listField, Graphics graphics,int index, int y, int width)
{
listField.invalidate(); //My try
...
}
But it doesn't run .
Update
Ok , no invalidate().
I'll show you my problem better with an Image:
Thanks for reading . Any idea?

What your code snippet will do is every time one row is drawn, invalidate the entire field causing all visible rows to be redrawn, which will invalidate the entire field...
I hope some one at RIM thought of that and aborts the invalidate call. I can't give you any more ideas without more specific information about what you are doing with your user interface.

Related

How to recalculate column widths on scroll down(not programmatic) to a previously hidden row of a Vaadin Grid when its HeightMode is CSS

My application is similar to Vaadin Dashboard Demo (please click login after you visit this link). So all my mini dashboard items are wrapped around an abstract component that is of height 300px. One of those items is a Grid wrapped around this 300px height abstract component.
My customer hates it when he sees a large column and .v-grid-cell cuts his cell off:
text-overflow: ellipsis;
So in the #PostConstruct of my Vaadin Grid(and everywhere I mess with the container) i have
this.recalculateColumnWidths();
to alleviate my customer's concern. I tell him he can resize the column but he is not satisfied.
When my container size is small, most of the rows are visible and hence the column widths are perfect. When i have a lot of rows i have to scroll. The column widths are calculated based on the set of initially visible rows. When i scroll down, and if a newly visible row has a large column then the column gets cut off.
I can alleviate my problem by using HeightMode.ROW and make the parent Component a scrolling Panel like:
panel.setWidth("100%");
panel.setHeight("310px");
But I have a lot of action going on my Grid's FooterRow and so i don't want my user to have to scroll to the bottom to see the footers if row size is say 100. As a result my Grid has default HeightMode -> HeightMode.CSS. I like it. It always shows my HeaderRow and FooterRow and scrolls only the rows section of my Grid.
What have i tried:
Give each column humongous size or expand ratio. Customer rejected it.
I tried adding a listener for scroll event unsuccessfully. I used this similar question mentions. I could not get the scroll listener turned on.
ScrollingGrid.java:
public class ScrollingGrid extends Grid{
List<ScrollingGridScrollListener> listeners = new ArrayList<ScrollingGridScrollListener>();
private void fireSrollEvent() {
for (ScrollingGridScrollListener listener : listeners) {
listener.doGridScroll();
}
}
public void addScrollListener(ScrollingGridScrollListener listener) {
listeners.add(listener);
}
#Override
public void beforeClientResponse(boolean initial) {
super.beforeClientResponse(initial);
fireSrollEvent();
}
}`
ScrollingGridScrollListener.java:
public interface ScrollingGridScrollListener {
public void doGridScroll();
}
and in my Grid:
addScrollListener(this);
and
#Override
public void doGridScroll() {
Notification.show("You are scrolling!\nYou can add your own behavior here!");
this.recalculateColumnWidths();
}
I see the notification when page loads. Maybe i should not override beforeClientResponse method in Grid. But I don't know what method to override to achieve a scroll listener.
Help me figure out this scroll listener or if there is another way i can get recalculated column widths on scroll, please let me know.
Thanks for reading this very long question.
Version: 7.6.8

Blackberry jumpy scroll

I am having trouble with vertical scrolling on a blackberry app.
it works just fine on touch screens, but when scrolling using a track pad, it jumps from being at the top position to being at the bottom position.
Anyone had a similar problem? any idea what i could try?
Here is a snippet from my code. i have a static background image and the fields scroll on top of it:
vertical_main = new VerticalFieldManager(USE_ALL_WIDTH |NO_VERTICAL_SCROLL |USE_ALL_HEIGHT);
vertical_AllTags=new VerticalFieldManager(USE_ALL_WIDTH | VERTICAL_SCROLL);
// i then add all the fields to vertical_AllTags
vertical_main.add(vertical_AllTags);
vertical_main.invalidate();
add(vertical_main);
thanks in advance for your help
EDIT:
The suggestion of giving each field focus was correct. the only other part that needs to be done is when you override the onFocus method for a field, you need to call the super() function so that all the other normal parts of the onFocus method are still called:
protected void onFocus(int direction) {
text_select=true;
invalidate();
super.onFocus(direction);
}
protected void onUnfocus() {
text_select=false;
invalidate();
super.onUnfocus();
}
Thank you so much.
This is common issue in non touch devises for beginners.
if you want to scroll field by field there is two ways
1) you need to give the focus to all fields then it will come field by
field focus down
another way is means you dont need to focus on each and every field
2)just add the NullField after your every field and give focus to all
NullFields then your trackball will bring your screen field by field
This happends beacuse in TrackWheel Scrolling it scrolls up to the next Focused field. I think you are not give any focus between the vertical_AllTags.
You can solved this by using NullField() class. Like...
add(new NullField(Field.FOCUSABLE))
when you add add(new NullField(Field.FOCUSABLE)); you will get the null focus which is not know by you. And you can navigate all the fields like Touch Screen.
You can solve that issue by adding two vertical field manager.. take a look at the code in this post

Blackberry return to the previus position in ListField

In my application I'm using a list.
This list can be updated by a refresh list button which is retriving more data from serever.
When user pressing the refresh button, my application seves the last selected item into a memeber field -
lastPosition = listField.getSelectedIndex();
After updating the list, my application uses -
listField.setSelectedIndex(lastPosition);
for setting the last position.
But nothing happen.
How can i "move" the list's cursor to point on the lastPosition?
Thanks,
Eyal.
listField.setKeyword("");
listField.v = userVector;
listField.updateList();
listField.getResultList();
listField.setSelectedIndex(lastPosition);
listField.setFocus();
Manager manager = listField.getManager();
int rowHeight = listField.getRowHeight();
manager.setVerticalScroll(lastPosition * rowHeight);
listField.invalidate();
It's hard to guess what is wrong without seeing the code, however the first thing that comes to mind is probably you don't set focus on the list right after you restore the position? If you don't, then try it:
listField.setSelectedIndex(lastPosition);
listField.setFocus();

Displaying images

Hi I am developing a application where I need to display number of images with some conditions. The images should display one by one on the screen when next button is clicked.Here the size of all images is 360x480.When the image is display then all other fields like next and previous buttons should be added to the screen.How to paint those images.Can anybody please help me in this regard.
You can display images with the BitmapField. Use the setBitmap() method to change the image.
Edit: Ok, so you would want to do something like this, put the names of all your bitmaps in an array, have the button's listeners increment or decrement the array index and display that bitmap. So your next button might look like this:
ButtonField nextButton = new ButtonField("Next");
nextButton.setChangeListener(new FieldChangeListener(){
public void fieldChanged(Field field, int context)
{
if(arrayIndex + 1 >= bitmapArray.length)
{
return;
}
arrayIndex++;
Bitmap image = Bitmap.getBitmapResource(bitmapArray[arrayIndex])
myBitmapField.setBitmap(image);
}
});
This assumes that your images are preloaded with your app and are stored in the 'res' directory, if you're downloading them from online or they're stored on the filesystem the way you load the bitmap will be somewhat different. I haven't compiled this code so it may have some bugs but this is roughly what you want to do.

Hightlight image within a vertical manager

So i have 3 images in a vertical field manager and each image is clickable and proceeds to the correct url. all that works. the only problem at this time is that when i scroll (up or down), i don't know which image is currently focused. i don't know until the browser opens the corresponding url.
so is there any way to get a border or a highlight to appear under my images (or within the manager) so that i can definitely see which image is currently focused? so if you think of a list, your selections are highlighted as you scroll up and down. i want something similar to that with my application.
thank you for your help.
ac
using the setSpace(int,int) method on the bitmap field worked great. this allowed me to see a border around the element that had focus.
override inline the bitmapfield drawFocus method. Something like this
protected void drawFocus(Graphics graphics, boolean on){
graphics.setBackgroundColor(0x00204020);
graphics.drawRect(0, 0, getBitmapWidth(), getBitmapHeight());
}

Resources