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);
}
}
No comments:
Post a Comment