如何将Onclick添加到Wheel菜单?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何将Onclick添加到Wheel菜单?相关的知识,希望对你有一定的参考价值。
我通过阅读本教程制作了旋转轮菜单。 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...
}
});
以上是关于如何将Onclick添加到Wheel菜单?的主要内容,如果未能解决你的问题,请参考以下文章
将数据从 RecyclerView.Adapter 传递到片段 onClick
如何在 Android 中将选项菜单添加到 Fragment