我的目标是在Android中创建一个星级字段,他们有一个评级星级字段。我已经到目前为止完成以下任务:
我的下一步是执行以下操作: 如果没有点击星1,那么后面的所有4颗星都不能被点击,如果点击星2,那么星3必须是可点击的,如果只选择了所有5颗星,那么星4-5必须是不可点击的(然后向后) star5必须是可点击的,如果第5和第4星没有被点击,那么star3必须是可点击的星星2-1必须是不可点击的等等。
我可以为您提供我到目前为止所做的代码片段(检查链接): http://supportforums.blackberry.com/t5/Java-Development/Rating-Stars-like-in-android/m-p/1942559
如果您对如何做我想做的事情有任何想法,请告诉我。谢谢。
答案 0 :(得分:0)
根据您的要求,本文对黑莓评级明星非常有用。
答案 1 :(得分:0)
LabelField RateDeal = new LabelField("Rating: ");
HorizontalFieldManager StarManager=new HorizontalFieldManager(USE_ALL_WIDTH);
final Bitmap StarNotClicked = Bitmap.getBitmapResource("rating_star.png");
final Bitmap StarClicked = Bitmap.getBitmapResource("rating_star_focus.png");
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);
AmountOfStarsSelected(1);
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);
AmountOfStarsSelected(2);
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);
AmountOfStarsSelected(3);
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);
AmountOfStarsSelected(4);
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);
AmountOfStarsSelected(5);
return true;
}
};
StarManager.add(Star1);
StarManager.add(Star2);
StarManager.add(Star3);
StarManager.add(Star4);
StarManager.add(Star5);
add(StarManager);