0
我只是下載輪式撿取器示例項目。在那個項目中,它在文本視圖中更新的輪式選取器中進行了更新。在這裏,我將該文本視圖更改爲按鈕,如果我單擊該按鈕,則表示它將顯示輪選取器中的值。它可能與否?Android輪式撿取器
這裏我的示例代碼:
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.test_wheel_layout);
bundle = new Bundle();
wheelArrayList = new ArrayList<String>();
bundle = getIntent().getExtras();
wheelArrayList = (ArrayList<String>) bundle.get("ItemKey");
wheelMenu1 = wheelArrayList.toArray(new String[wheelArrayList.size()]);
initWheel1(R.id.p1);
btnCurrentSelection = (Button) this.findViewById(R.id.btn_FrstSelection);
btnCurrentSelection.setText(bundle.getString("selectedValue"));
btnCurrentSelection.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//OnWheelChangedListener();
}
});
}
// Wheel scrolled listener
OnWheelScrollListener scrolledListener = new OnWheelScrollListener()
{
public void onScrollStarts(WheelView wheel)
{
wheelScrolled = true;
}
public void onScrollEnds(WheelView wheel)
{
wheelScrolled = false;
updateStatus();
}
};
// Wheel changed listener
private final OnWheelChangedListener changedListener = new OnWheelChangedListener()
{
public void onChanged(WheelView wheel, int oldValue, int newValue)
{
if (!wheelScrolled)
{
updateStatus();
}
}
};
/**
* Updates entered PIN status
*/
private void updateStatus()
{
PreferenceConnector.writeString(WheelActivity.this, itemKeyName, wheelMenu1[getWheel(R.id.p1).getCurrentItem()]);
}
}
/**
* Initializes wheel
*
* @param id
* the wheel widget Id
*/
private void initWheel1(int id)
{
WheelView wheel = (WheelView) findViewById(id);
wheel.setAdapter(new ArrayWheelAdapter<String>(wheelMenu1));
wheel.setVisibleItems(5);
wheel.setCurrentItem(0);
// text.setText(""+wheel.getCurrentItem());
wheel.addChangingListener(changedListener);
wheel.addScrollingListener(scrolledListener);
}
/**
* Returns wheel by Id
*
* @param id
* the wheel Id
* @return the wheel with passed Id
*/
private WheelView getWheel(int id)
{
return (WheelView) findViewById(id);
}
/**
* Tests wheel value
*
* @param id
* the wheel Id
* @param value
* the value to test
* @return true if wheel value is equal to passed value
*/
private int getWheelValue(int id)
{
return getWheel(id).getCurrentItem();
}
任何一個可以幫助我,如何集中