09-12-2011 03:55 AM
Hi
I have three fieldManagers arranged horizontally in which contents of
middle fieldmanager will change on button click
is it possible to apply slide in - slide out effect to these contents?
i dont want to redraw whole screen again n again?
Solved! Go to Solution.
09-12-2011 04:41 AM
You can achieve a transition effect for a HFM by just having a Thread that changes the horizontalScrollPosition every, say 100 milliseconds, Say where you want to go is position 500 and you are currently at 100, then if you do 4 100 pixel movements, it looks like it is sliding. I don't have any useful code that does this, it is just an idea. But give it a try if you don't find any other way.
09-13-2011 09:34 AM
Hi peter_strange
I tried with your suggestion and partly succeeded in slide-in / out effect
but manager can only be slide in from left side of screen only.
I want manager to slide in from right side of the screen.
what could be the possible solution for this ??
09-13-2011 10:01 AM
Wrap the middle manager in a HorizontalFieldManager(HORIZONTAL_SCROLL). When you want to slide out the old content and slide in the new one, do the following:
1) add the new content to the HFM;
2) make an animation sliding from the left boundary of the old content (probably 0) to the left boundary of the new one (getLeft() returns the value). Use the method suggested by Peter;
3) Once the animation has finished, delete the old content and setHorizontalScroll on the enveloping HFM to 0 (since the new content now starts there).
09-13-2011 10:13 AM
Hi arkadyz and peter
Thanx for useful suggestions![]()
As peter suggested, i am succeeded to implement Transition effect for HFM from Left To Right
is it possible to apply reverse effect (Right to Left) for the same
so that HFM will seems to be sliding in from right side of the screen?
09-13-2011 11:21 AM
But that's exactly what I suggested - see my previous reply to make your manager "slide" from right to left...
09-26-2011 07:02 AM
Hi peter,
As u have explained i have created a class that does the sliding effect for the field.. and here is the class.
class CentricHManager extends HorizontalFieldManager {
int focusedFieldIndex = 0;
private int[] xPositions;
int scroll;
int scrollpos = 0;
boolean isKeepGoing = true;
int middlePoint;
int position;
int focusedFieldIndexNew;
CentricHManager(){
super(Manager.HORIZONTAL_SCROLL);
}
protected void sublayout(int maxWidth, int maxHeight) {
int x = 0;
xPositions = new int[getFieldCount()];
for (int i = 0; i < getFieldCount(); i++) {
layoutChild(getField(i), 0, maxHeight);
setPositionChild(getField(i), x , 0);
xPositions[i] = x;
//System.out.println("Xposition of "+i+" is "+xPositions[i]);
x = x + getField(i).getWidth();
}
setExtent(getPreferredWidth(),getPreferredHeight() );
}
public void focusChangeNotify(int arg0) {
super.focusChangeNotify(arg0);
focusedFieldIndexNew = getFieldWithFocusIndex();
if (focusedFieldIndexNew != focusedFieldIndex && focusedFieldIndexNew < getFieldCount()) {
scrollpos = this.getHorizontalScroll();
position = xPositions[focusedFieldIndexNew];
isKeepGoing = true;
System.out.println("scrollpos is "+ scrollpos);
System.out.println("position is "+ position);
if (focusedFieldIndexNew - focusedFieldIndex > 0){
if(focusedFieldIndexNew == getFieldCount() - 1){
middlePoint = Display.getWidth() - getField(focusedFieldIndexNew).getWidth();
scroll = position - middlePoint;
}else {
middlePoint = (Display.getWidth() - getField(focusedFieldIndexNew).getWidth())/2;
scroll = position - middlePoint;
}
System.out.println("middlePoint is "+ middlePoint);
System.out.println("scroll is "+ scroll);
if(focusedFieldIndexNew != 0 && !(scroll < 0)){
new Thread(){
public void run(){
while(isKeepGoing){
try{
scrollpos = scrollpos + 1;
System.out.println("scrollpos is "+ scrollpos);
if(scrollpos < scroll){
isKeepGoing = true;
CentricHManager.this.setHorizontalScroll(scrollpos );
}else {
isKeepGoing = false;
CentricHManager.this.setHorizontalScroll(scroll);
}
sleep(1);
}catch(Exception e){
System.out.println("Exception Thrown here :"+ e);
}
}
}
}.start();
}
} else {
if(focusedFieldIndexNew == 0){
scroll = 0;
}else {
middlePoint = (Display.getWidth() - getField(focusedFieldIndexNew).getWidth())/2;
scroll = position - middlePoint;
}
System.out.println("middlePoint is "+ middlePoint);
System.out.println("scroll is "+ scroll);
if(focusedFieldIndexNew != getFieldCount()-1 && !(scroll < 0)){
new Thread(){
public void run(){
while(isKeepGoing){
try{
scrollpos = scrollpos - 1;
System.out.println("scrollpos is "+ scrollpos);
if(scrollpos > scroll){
isKeepGoing = true;
CentricHManager.this.setHorizontalScroll(scrollpos );
}else {
isKeepGoing = false;
CentricHManager.this.setHorizontalScroll(scroll);
}
sleep(1);
}catch(Exception e){
System.out.println("Exception Thrown here :"+ e);
}
}
}
}.start();
}
}
focusedFieldIndex = focusedFieldIndexNew;
}
}
public void add(Field field) {
super.add(field);
}
}this works fine for 5.0 device. for for below that... 4.5 device throw exception -- java.lang.IllegalStateException: UI engine accessed without holding the event lock. it will work but no sliding effect. can you please help me for this.
This question is related to this thread, thats why i am asking here itself.
Thanks & Regards
pp
09-26-2011 07:11 AM
Hi,
sorry peter. it was my mistake.
i was trying to make a UI change without holding the UI event lock. and now i solved it.
Thanks & Regards
pp
02-17-2012 04:02 AM
Hi
I have added four Bitmapfields to this CentricHManager and they were not even visible on the device screen. Can you please let me know to add the fields to this and make it slide.
04-27-2012 10:04 AM
i have created 7 Bitmap field and add to this class but my bitmap images are not visible can u help me to sought out this problem.