05-03-2012 05:51 AM
Hi all,
i am trying to develop a program where in a picture scroller appears at the bottom of the mobile screen, but am not able to figure out layout managers, the screen appears just plain white. Please help,
Here is the code below for screen
public class MobiletvMainScreen extends MainScreen {
VerticalFieldManager Vfm;
//HorizontalFieldManager Hfm;
FieldManager fm = new FieldManager();
//Determine half of the screen Height.
//int Sheight = Graphics.getScreenHeight() / 3;
//int Swidth = Graphics.getScreenWidth();
MobiletvMainScreen() {
Vfm = new VerticalFieldManager(USE_ALL_WIDTH);
//Hfm = new HorizontalFieldManager(FIELD_BOTTOM);
Bitmap images[] = new Bitmap[9];
String[] labels = new String[9];
String[] tooltips = new String[9];
ScrollEntry[] entries= new ScrollEntry[9];
for (int i = 0; i < entries.length; i++)
{
imgIndex = i+1;
images[i] = Bitmap.getBitmapResource("resource/pic" + imgIndex+ ".png");
labels [i] = "Label for image" + imgIndex;
tooltips[i] = "Tooltips for image" +imgIndex;
entries[i] = new ScrollEntry(images[i], labels[i], tooltips[i]);
}
PictureScroll pictureScroll = new PictureScroll(entries);
fm.add(pictureScroll);
Vfm.add(fm);
add(Vfm);
}
private class PictureScroll extends PictureScrollField {
private final ScrollEntry[] _entries;
PictureScroll(ScrollEntry[] entries) {
super(200,327);
_entries = entries;
this.setImageDistance(50);
this.setData(entries, 0);
this.setHighlightStyle(HighlightStyle.ILLUMINATE_W
this.setHighlightBorderColor(Color.BLUE);
}
}
}
Here is the Fieldmanager Class
public class FieldManager extends Manager{
FieldManager() {
super(FIELD_BOTTOM);
}
//int Swidth = Graphics.getScreenWidth();
//int Sheight = Graphics.getScreenHeight()/3;
protected void sublayout(int width, int height) {
//if (getFieldCount() > 0) {
Field centeredField = getField(0);
layoutChild(centeredField, getPreferredwidth(), getPreferredheight());
setPositionChild(centeredField,getPreferredwidth()
setExtent(Graphics.getScreenWidth(), Graphics.getScreenHeight()/2);
}
05-03-2012 09:32 AM
Hello ,
If you required to add the contents in botton of screen.
Then add your content in vfm in your code and replace add(vfm) as a setStatus(vfm).
Please tell me my solution is work or not.
05-04-2012 01:22 AM
thanks Aniruddha... but its not working.
(
05-10-2012 06:51 AM
Hello Henna,
Please try this code it works properly. It is solve your issue. Picture scroll field set at the bottom of screen.
package mypackage;
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.extension.component.PictureS
import net.rim.device.api.ui.extension.component.PictureS
public class MobiletvMainScreen extends MainScreen {
MobiletvMainScreen() {
Bitmap images[] = new Bitmap[9];
String[] labels = new String[9];
String[] tooltips = new String[9];
ScrollEntry[] entries = new ScrollEntry[9];
for (int i = 0; i < entries.length; i++) {
int imgIndex = i + 1;
images[i] = Bitmap.getBitmapResource("first.png");// ("res/pic" +
// imgIndex +
// ".png");
labels[i] = "Label for image" + imgIndex;
tooltips[i] = "Tooltips for image" + imgIndex;
entries[i] = new ScrollEntry(images[i], labels[i], tooltips[i]);
}
PictureScroll pictureScroll = new PictureScroll(entries);
add(pictureScroll);
}
private class PictureScroll extends PictureScrollField {
private final ScrollEntry[] _entries;
PictureScroll(ScrollEntry[] entries) {
super(100, 100);
_entries = entries;
this.setImageDistance(70);
this.setData(_entries, 0);
this.setHighlightStyle(HighlightStyle.ILLUMINATE_
this.setHighlightBorderColor(Color.BLUE);
this.setPadding(250, 0, 0, 0);
}
}
}
Thanks!!
Regards,
Aniruddha
05-10-2012 06:55 AM
05-10-2012 07:02 AM
Hello ,
If you want to set using custom layout manager then please refere below link.
Thanks!!
Regards,
Aniruddha
05-11-2012 05:46 AM
More current version of the link supplied above and another useful link:
http://supportforums.blackberry.com/t5/Java-Develo