10-10-2012 03:24 AM
Hi all, my goal is to create a star field like in android they have a rating star field. i have come as far to accomplish the following:
My next step is to do the following:
if star 1 is not clicked then all 4 stars after must not be clickable, if star 2 is clicked then star 3 must be clickable and stars 4-5 must not be clickable, (and then backwards) if all 5 stars have been selected only star5 must be clickable, if star 5 and 4 are unclicked then star3must be clickable stars 2-1 must not be clickable, etc.
I can supply you with a code snippet with what I have done so far:
public class MyScreen extends MainScreen{
boolean check=false;
Bitmap bitmap;
HorizontalFieldManager StarManager=new HorizontalFieldManager(USE_ALL_WIDTH);
final Bitmap StarNotClicked = Bitmap.getBitmapResource("rating_star.png");
final Bitmap StarClicked = Bitmap.getBitmapResource("rating_star_focus.png");
BitmapField Star1;
BitmapField Star2;
BitmapField Star3;
BitmapField Star4;
BitmapField Star5;
public MyScreen(){
Star1 = new BitmapField(StarNotClicked,BitmapField.FOCUSABLE){
protected boolean navigationClick(int status, int time){
fieldChangeNotify(1);
if(check==true){
this.setBitmap(StarNotClicked);
check=false;
}else{
this.setBitmap(StarClicked);
check=true;
}
return true;
}
};
Star2 = new BitmapField(StarNotClicked,BitmapField.FOCUSABLE){
protected boolean navigationClick(int status, int time){
fieldChangeNotify(1);
if(check==true){
this.setBitmap(StarNotClicked);
check=false;
}else{
this.setBitmap(StarClicked);
check=true;
}
return true;
}
};
Star3 = new BitmapField(StarNotClicked,BitmapField.FOCUSABLE){
protected boolean navigationClick(int status, int time){
fieldChangeNotify(1);
if(check==true){
this.setBitmap(StarNotClicked);
check=false;
}else{
this.setBitmap(StarClicked);
check=true;
}
return true;
}
};
Star4 = new BitmapField(StarNotClicked,BitmapField.FOCUSABLE){
protected boolean navigationClick(int status, int time){
fieldChangeNotify(1);
if(check==true){
this.setBitmap(StarNotClicked);
check=false;
}else{
this.setBitmap(StarClicked);
check=true;
}
return true;
}
};
Star5 = new BitmapField(StarNotClicked,BitmapField.FOCUSABLE){
protected boolean navigationClick(int status, int time){
fieldChangeNotify(1);
if(check==true){
this.setBitmap(StarNotClicked);
check=false;
}else{
this.setBitmap(StarClicked);
check=true;
}
return true;
}
};
StarManager.add(Star1);
StarManager.add(Star2);
StarManager.add(Star3);
StarManager.add(Star4);
StarManager.add(Star5);
add(StarManager);
}
}
Please let me know if you have any idea on how to do what I would like to achieve , thank you.
Solved! Go to Solution.
10-10-2012 03:35 AM
10-10-2012 03:52 AM
Okay i did some research, to get cookie -Retrieves previously set cookie, and set cookie- Sets a cookie object for later retrieval.
Field.setcookie(object);
Field.getCookie() ;
by set cookie, where the "object" is, is that where I set the "additional Status"?
Would you suggest I set these status's in the Navigation onclick function in my above code snippet?
I started a new thread because i found the answer to my previous one and now that I started a new one I also got a quick response ![]()
Thank you Simon_hain
10-10-2012 04:03 AM
10-10-2012 04:20 AM
okay I understand how to do that... but now what i dont understand is how to make the other starfields "Unclickable".
Star2 = new BitmapField(StarNotClicked,BitmapField.FOCUSABLE){
protected boolean navigationClick(int status, int time){
fieldChangeNotify(1);
if(check==true){
this.setBitmap(StarNotClicked);
check=false;
}else{
this.setBitmap(StarClicked);
check=true;
}
return true;
}
};
as you can see here I added in the boolean to store the status , but what funcion could I use to disable the other fields, that is my problem...
10-10-2012 04:37 AM
10-10-2012 05:50 AM
a friend of mine gave me a hand and this seems to do the trick (the easy long way
) :
Star1 = new BitmapField(StarNotClicked,BitmapField.FOCUSABLE){
protected boolean navigationClick(int status, int time){
fieldChangeNotify(1);
Star1.setBitmap(StarClicked);
Star2.setBitmap(StarNotClicked);
Star3.setBitmap(StarNotClicked);
Star4.setBitmap(StarNotClicked);
Star5.setBitmap(StarNotClicked);
return true;
}
};
Star2 = new BitmapField(StarNotClicked,BitmapField.FOCUSABLE){
protected boolean navigationClick(int status, int time){
fieldChangeNotify(1);
Star1.setBitmap(StarClicked);
Star2.setBitmap(StarClicked);
Star3.setBitmap(StarNotClicked);
Star4.setBitmap(StarNotClicked);
Star5.setBitmap(StarNotClicked);
return true;
}
};
Star3 = new BitmapField(StarNotClicked,BitmapField.FOCUSABLE){
protected boolean navigationClick(int status, int time){
fieldChangeNotify(1);
Star1.setBitmap(StarClicked);
Star2.setBitmap(StarClicked);
Star3.setBitmap(StarClicked);
Star4.setBitmap(StarNotClicked);
Star5.setBitmap(StarNotClicked);
return true;
}
};
Star4 = new BitmapField(StarNotClicked,BitmapField.FOCUSABLE){
protected boolean navigationClick(int status, int time){
fieldChangeNotify(1);
Star1.setBitmap(StarClicked);
Star2.setBitmap(StarClicked);
Star3.setBitmap(StarClicked);
Star4.setBitmap(StarClicked);
Star5.setBitmap(StarNotClicked);
return true;
}
};
Star5 = new BitmapField(StarNotClicked,BitmapField.FOCUSABLE){
protected boolean navigationClick(int status, int time){
fieldChangeNotify(1);
Star1.setBitmap(StarClicked);
Star2.setBitmap(StarClicked);
Star3.setBitmap(StarClicked);
Star4.setBitmap(StarClicked);
Star5.setBitmap(StarClicked);
return true;
}
};