Board logo

標題: Android App - 按相同spinner item 可觸發 event [打印本頁]

作者: admin    時間: 2012-6-24 19:50     標題: Android App - 按相同spinner item 可觸發 event

spinner.setOnClickListener(new
View.OnClickListener()
{
public
void onClick(View v)
{
// Do some stuff before the user changes the selection
...

spinner.setOnItemSelectedListener(new
OnItemSelectedListener()
{
@Override
public
void onItemSelected(AdapterView<?> parent,
View view,
int pos,
long id)
{
// Do some stuff based onItemSelected

You will have to set the Click listener on the underlying view (normally a TextView with id: android.R.id.text1) of the spinner. To do so:




參考
http://stackoverflow.com/questions/4130561/triggering-locationlisteners-event-manually

http://www.mkyong.com/android/android-spinner-drop-down-list-example/ <-- worth studying


搜尋字 "android spinner fire event when same item is selected"




歡迎光臨 How2Do (http://forum.how2do.com.hk/) Powered by Discuz! 7.2