我通过阅读本教程制作了旋转轮菜单。 http://developer.digitalaria.com/devguide/gama/en/gama/wheel_android.php
它正在工作。但我不知道如何将Onclick方法添加到此Wheel菜单。
**活动**
public class SampleWheelActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
init();
}
private Wheel wheel;
private Resources res;
private int[] icons = {
R.drawable.icon00, R.drawable.icon01, R.drawable.icon02,
R.drawable.icon03, R.drawable.icon04, R.drawable.icon05,
R.drawable.icon06, R.drawable.icon07, R.drawable.icon08,
R.drawable.icon09, R.drawable.icon10, R.drawable.icon11 };
private void init() {
res = getApplicationContext().getResources();
wheel = (Wheel) findViewById(R.id.wheel);
wheel.setItems(getDrawableFromData(icons));
wheel.setWheelDiameter(400);
}
private Drawable[] getDrawableFromData(int[] data) {
Drawable[] ret = new Drawable[data.length];
for (int i = 0; i < data.length; i++) {
ret[i] = res.getDrawable(data[i]);
}
return ret;
}
}
我从未使用过他们的API,但他们确实提供了文档:
http://developer.digitalaria.com/reference/en/gama/android/
wheel.setOnItemClickListener(new WheelAdapter.OnItemClickListener() {
@Override
public void onItemClick(WheelAdapter<?> parent, View view, int position, long id) {
// add your code here...
}
});