2012-12-27 28 views
1

我在我的android應用程序中使用Wheelview作爲Datepicker,並且需要例如「January」的選定項目。我嘗試了getCurrentItem(),但我想它只是得到的物品位置不是確切的文字。獲取在android中的選定項目wheelview

這裏是我的代碼

WheelView wheelview = new (WheelView) findViewById(R.id.wheelview1); 
String[] ampArray = new String[] {"January", February", "March"} 
ArrayWheelAdapter<String> amp = new ArrayWheelAdapter<String>(this, ampArray); 
wheelview.setViewAdapter(amp); 
wheelview.getCurrentItem(); 

任何人都可以有關於他的一個更好的辦法? 謝謝。

+0

能否請您提供一些代碼? –

+0

你可以看到[this](http://w2davids.wordpress.com/advanced-android-ui-wheelpicker/)從wheelview中獲取選定文本的例子 –

+0

我不能用這行text1.setText(wheelMenu1 [getWheel( R.id.p1).getCurrentItem()]); –

回答

2

獲取當前文本從WheelView爲:

String strselected_txt=ampArray[wheelview.getCurrentItem()]; 
+0

先生您是否知道如何使用wheelview顯示圖像?或任何鏈接? –

+0

@GangnaminmoAko:k讓我檢查如果可能的話我會給你正確的鏈接 –

+0

好的非常感謝你 –

0
protected WheelView getWheel(int id) { 
     // TODO Auto-generated method stub 
     return (WheelView) findViewById(id); 
    } 


String variable_name = (ampArray[getWheel(R.id.WheelView_Name).getCurrentItem()]);