The following code will display splash screen.
public class App extends UiApplication {
public static App theApp;
public static void main(String[] args) {
theApp = new App();
theApp.enterEventDispatcher();
}
public App() {
splash next = null;
splash1 splash1=new splash1(this ,next);
pushScreen(splash1);
}
}
splash1 class is given below-
public splash1(UiApplication app, splash next){
application=app;
VerticalFieldManager vfm=new VerticalFieldManager();
final Bitmap header_Bitmap =Bitmap.getBitmapResource("splash.png");
BitmapField bit =new BitmapField(header_Bitmap);
vfm.add(bit);
add(vfm);
timer = new Timer();
timer.schedule(new CountDown(), 1000);
}
public class CountDown extends TimerTask {
public void run() {
DismissThread dThread = new DismissThread();
application.invokeLater(dThread);
}
}
public void dismiss() {
timer.cancel();
application.popScreen(this);
application.pushScreen(next);
}
public class DismissThread implements Runnable {
public void run() {
dismiss();
}
}
}
splash class is the landing page(Home page)-
public class splash extends MainScreen {
public splash(){
//Here you can add your fields.......
}
}
Friday, September 20, 2013
Splash / Loading Screen in Blackberry
Thursday, September 5, 2013
Creating Facebook Like Slider Menu in Blackberry
For creating a sliding bar like android facebook app, refer the following code. You have to customize it. Its only give you the idea. you have to implement it in your own way.
public final class MyScreen extends MainScreen
{
boolean val=false;
VerticalFieldManager vfm_r1;
public MyScreen()
{
final ButtonField l=new ButtonField("menu");
final HorizontalFieldManager hfm_main=new HorizontalFieldManager();
final VerticalFieldManager vfm_l=new VerticalFieldManager(){
protected void sublayout(int maxWidth, int maxHeight) {
super.sublayout(280, maxHeight);
setExtent(280, maxHeight);
}
protected void paint(Graphics g){
g.setBackgroundColor(Color.RED);
// Clears the entire graphic area to the current background
g.clear();
super.paint(g);
}
};
final VerticalFieldManager vfm_r=new VerticalFieldManager(){
protected void sublayout(int maxWidth, int maxHeight) {
super.sublayout(maxWidth+300, maxHeight);
setExtent(maxWidth, maxHeight);
}
protected void paint(Graphics g){
g.setBackgroundColor(Color.YELLOW);
// Clears the entire graphic area to the current background
g.clear();
super.paint(g);
}
};
vfm_l.add(new LabelField("sliding pannel"));
vfm_r.add(l);
vfm_r.add(new LabelField("main view"));
hfm_main.add(vfm_r);
add(hfm_main);
FieldChangeListener listener=new FieldChangeListener() {
public void fieldChanged(Field field, int context) {
if(field==l){
if(!val){
val=true;
hfm_main.deleteAll();
hfm_main.add(vfm_l);
hfm_main.add(vfm_r);
hfm_main.invalidate();
}else{
val=false;
hfm_main.deleteAll();
hfm_main.add(vfm_r);
hfm_main.invalidate();
}
}
}
};
l.setChangeListener(listener);
}
}
public final class MyScreen extends MainScreen
{
boolean val=false;
VerticalFieldManager vfm_r1;
public MyScreen()
{
final ButtonField l=new ButtonField("menu");
final HorizontalFieldManager hfm_main=new HorizontalFieldManager();
final VerticalFieldManager vfm_l=new VerticalFieldManager(){
protected void sublayout(int maxWidth, int maxHeight) {
super.sublayout(280, maxHeight);
setExtent(280, maxHeight);
}
protected void paint(Graphics g){
g.setBackgroundColor(Color.RED);
// Clears the entire graphic area to the current background
g.clear();
super.paint(g);
}
};
final VerticalFieldManager vfm_r=new VerticalFieldManager(){
protected void sublayout(int maxWidth, int maxHeight) {
super.sublayout(maxWidth+300, maxHeight);
setExtent(maxWidth, maxHeight);
}
protected void paint(Graphics g){
g.setBackgroundColor(Color.YELLOW);
// Clears the entire graphic area to the current background
g.clear();
super.paint(g);
}
};
vfm_l.add(new LabelField("sliding pannel"));
vfm_r.add(l);
vfm_r.add(new LabelField("main view"));
hfm_main.add(vfm_r);
add(hfm_main);
FieldChangeListener listener=new FieldChangeListener() {
public void fieldChanged(Field field, int context) {
if(field==l){
if(!val){
val=true;
hfm_main.deleteAll();
hfm_main.add(vfm_l);
hfm_main.add(vfm_r);
hfm_main.invalidate();
}else{
val=false;
hfm_main.deleteAll();
hfm_main.add(vfm_r);
hfm_main.invalidate();
}
}
}
};
l.setChangeListener(listener);
}
}
Subscribe to:
Posts (Atom)