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.
Related
I have a fiddle at http://jsfiddle.net/k8XCP/1/ where I'm trying to create a helper that consists of the original thumb being dragged plus an image that shows the user a tip. It's trying to work, but it has two problems:
The combined helper being dragged (newHelper) starts off where the newHelper div was laid down, even though I try to set the newHelper offset to the e.clientX/e.clientY of the click. I'd like the helper to start where the thumb is.
After I drop the helper, the original thumb in the gallery div is gone, and dragging has broken so that I can't drag the second image.
I build the newHelper with
function buildHelper (){
$(this).prependTo('#newHelper'); // this keyword is the thumb
return $('#newHelper');
}
Does anyone see what I'm doing wrong?
Thanks
For the buildHelper function to work as expected, it has to return a clone of the original element that you want to drag + clone of #newHelper .
I think there are better solutions to this problem, but for your example this will work;
function buildHelper() {
return $("#newHelper").clone().append($(this).clone());
}
You can view an example of this: http://jsfiddle.net/Rusln/EXQhx/
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.
I'm using a PictureScrollField in a VerticalFieldManager with other fields that need focus. When the PictureScrollField receives focus, the images are shown in their original form. But when I remove focus, by default, the field draws a white square over the images. I looked around in the API and couldn't find a way to undo this default property. How to remove these squares?
This is the image when the field has focus-
And this is when the field loses focus-
You can see how the images have white overlays which look bad for non rectangular transparent images.
The solution is pretty simple - override onUnfocus method as
protected void onUnfocus(){
/*do nothing to prevent BB default image highlight*/
/*or do your own thing*/
}
Is there a way of doing this without using a QItemDelegate? I've been having a lot of trouble with it. For example, if I use a Delegate:
Won't have a native dialog.
I'll have to implement my own image preview,
For some reason I can't resize the window cause setGeometry doesn't work, etc etc.
QWidget *createEditor(
QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index
) const {
Q_UNUSED(option);
Q_UNUSED(index);
QFileDialog* editor = new QFileDialog(parent);
editor->setFilter("*.png");
editor->setDirectory(mResources);
editor->setGeometry(0,0,1000,500);
editor->exec() // <--- big file dialog;
return editor; // <--- tiny file dialog;
};
In practice, everything that changes the geometry of your widget goes to updateEditorGeometry function. Override it to avoid trying the original one to put your dialog within the cell of the table.
OK so the editor->setGeometry method has to go in the overridden method setEditorData of the QItemDelegate.
Does anyone know of an example code where the setItemDelegate is used to paint the thumbnail preview of the images in the QFileDialog?
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());
}