Java Code Examples for android.widget.AdapterView.OnItemSelectedListener

The following are top voted examples for showing how to use android.widget.AdapterView.OnItemSelectedListener. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: tuxguitar   File: TGBrowserView.java   View source code 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void refreshCollections() {
	ArrayAdapter<TGSelectableItem> arrayAdapter = new ArrayAdapter<TGSelectableItem>(findActivity(), R.layout.view_browser_spinner_item, createCollectionValues());
	arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
	
	TGSelectableItem selectedItem = new TGSelectableItem(findCurrentCollection(), null);
	Integer selectedItemPosition = arrayAdapter.getPosition(selectedItem);
	
	Spinner spinner = (Spinner) this.findViewById(R.id.browser_collections);
	OnItemSelectedListener listener = spinner.getOnItemSelectedListener();
	spinner.setOnItemSelectedListener(null);
	if(!this.isSameCollection(arrayAdapter, (ArrayAdapter<TGSelectableItem>) spinner.getAdapter())) {
		spinner.setAdapter(arrayAdapter);
	}
	if( spinner.getSelectedItemPosition() != selectedItemPosition ) {
		spinner.setSelection(selectedItemPosition, false);
	}
	spinner.setOnItemSelectedListener(listener);
}
 
Example 2
Project: financisto1-holo   File: DateFilterActivity.java   View source code 6 votes vote down vote up
private void createPeriodsSpinner() {
    spinnerPeriodType = (Spinner) findViewById(R.id.period);
    spinnerPeriodType.setAdapter(createSpinnerAdapter(this, periods));
    spinnerPeriodType.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            PeriodType period = periods[position];
            if (period == PeriodType.CUSTOM) {
                selectCustom();
            } else {
                selectPeriod(period);
            }
        }
        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
        }
    });
}
 
Example 3
Project: TuxGuitar-1.3.1-fork   File: TGBrowserView.java   View source code 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void refreshCollections() {
	ArrayAdapter<TGSelectableItem> arrayAdapter = new ArrayAdapter<TGSelectableItem>(findActivity(), R.layout.view_browser_spinner_item, createCollectionValues());
	arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
	
	TGSelectableItem selectedItem = new TGSelectableItem(findCurrentCollection(), null);
	Integer selectedItemPosition = arrayAdapter.getPosition(selectedItem);
	
	Spinner spinner = (Spinner) this.findViewById(R.id.browser_collections);
	OnItemSelectedListener listener = spinner.getOnItemSelectedListener();
	spinner.setOnItemSelectedListener(null);
	if(!this.isSameCollection(arrayAdapter, (ArrayAdapter<TGSelectableItem>) spinner.getAdapter())) {
		spinner.setAdapter(arrayAdapter);
	}
	if( spinner.getSelectedItemPosition() != selectedItemPosition ) {
		spinner.setSelection(selectedItemPosition, false);
	}
	spinner.setOnItemSelectedListener(listener);
}
 
Example 4
Project: flowzr-android-black   File: DateFilterActivity.java   View source code 6 votes vote down vote up
private void createPeriodsSpinner() {
    spinnerPeriodType = (Spinner) findViewById(R.id.period);
    spinnerPeriodType.setAdapter(createSpinnerAdapter(this, periods));
    spinnerPeriodType.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            if (position<0) {
                position=0;
            }
            PeriodType period = periods[position];
            if (period == PeriodType.CUSTOM) {
                selectCustom();
            } else {
                selectPeriod(period);
            }

        }
        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
        }
    });
}
 
Example 5
Project: flowzr-android-black   File: DateFilterFragment.java   View source code 6 votes vote down vote up
private void createPeriodsSpinner() {
    spinnerPeriodType = (Spinner) getView().findViewById(R.id.period);
    spinnerPeriodType.setAdapter(createSpinnerAdapter(getContext(), periods));
    spinnerPeriodType.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (position>0) {
	PeriodType period = periods[position];
	if (period == PeriodType.CUSTOM) {
		selectCustom();
	} else {
		selectPeriod(period);
	}
}
        }
        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
        }
    });
}
 
Example 6
Project: PdDroidPublisher   File: MidiConfigDialog.java   View source code 6 votes vote down vote up
protected void refreshInputList() {
	OnItemSelectedListener listener = midiInSpinner.getOnItemSelectedListener();
	midiInSpinner.setOnItemSelectedListener(null);
	midiInArrayList.clear();
	midiInArrayList.add(new MidiPortAdapter());
	int position = 0;
	for (MidiDevice midiDevice : midiManager.getDeveices()) {
		for (MidiInput midiInput : midiDevice.getInputs()) {
			if (midiInput == midiManager.getInput()) {
				position = midiInArrayList.getCount();
			}
			midiInArrayList.add(new MidiPortAdapter(midiDevice, midiInput));
		}
	}
	midiInSpinner.setSelection(position);
	midiInSpinner.setOnItemSelectedListener(listener);
}
 
Example 7
Project: WikiCards   File: MainActivity.java   View source code 6 votes vote down vote up
private void initCategorySpinner() {
  categoryAdapter = new CategoryListAdapter(this);
  categorySpinner = (Spinner) this.findViewById(R.id.spinner_category);
  categorySpinner.setAdapter(categoryAdapter);
  categorySpinner.setSelection(readSelectedCategory() - 1);
  categorySpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

    @Override
    public void onItemSelected(AdapterView<?> parent, View view, int idx,
            long id) {
      switchSelectedCategory((int) id);
      storage = new WordsStorage(MainActivity.this, (int) id);
      langAdapter.notifyDataSetChanged();
    }

    @Override
    public void onNothingSelected(AdapterView<?> arg0) {
      // Do nothing in this case.
    }
  });
}
 
Example 8
Project: twitterwidget   File: TimeLineFragmentConfig.java   View source code 6 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
	super.onActivityCreated(savedInstanceState);
	applyButton.setOnClickListener(new OnClickListener() {

		@Override
		public void onClick(View v) {
			onApplyButtonClick();
		}
	});
	tweetListSpinner
			.setOnItemSelectedListener(new OnItemSelectedListener() {

				@Override
				public void onItemSelected(AdapterView<?> parent,
						View view, int position, long id) {
					onSpinnerItemSelected(position);
				}

				@Override
				public void onNothingSelected(AdapterView<?> arg0) {
				}
			});
}
 
Example 9
Project: YiBo   File: AddAccountActivity.java   View source code 6 votes vote down vote up
private void bindEvent() {
	Button btnBack = (Button) this.findViewById(R.id.btnBack);
	btnBack.setOnClickListener(new GoBackClickListener(R.anim.slide_in_right));

	spServiceProvider.setAdapter(new ServiceProviderSpinnerAdapter(this));
	OnItemSelectedListener spItemListener = new AddAccountSpItemSelectedListener(this);
	spServiceProvider.setOnItemSelectedListener(spItemListener);
	
	
	spConfigApp.setAdapter(new ConfigAppSpinnerAdapter(this));
	OnItemSelectedListener configAppItemSelectedListener = null;
	configAppItemSelectedListener = new AddAccountConfigAppItemSelectedListener(this);
	spConfigApp.setOnItemSelectedListener(configAppItemSelectedListener);
	
	TextWatcher editTextWatcher = new AddAccountTextWatcher(this);
	etUsername.addTextChangedListener(editTextWatcher);
	etPassword.addTextChangedListener(editTextWatcher);
	etRestProxy.addTextChangedListener(editTextWatcher);
	etSearchProxy.addTextChangedListener(editTextWatcher);

	AddAccountAuthorizeClickListener authorizeClickListener = null;
	authorizeClickListener = new AddAccountAuthorizeClickListener(this);
	btnAuthorize.setOnClickListener(authorizeClickListener);

}
 
Example 10
Project: encdroidMC   File: ConfigSyncActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_config_sync);
	

	
	volumeName = (EditText) findViewById(R.id.volumeName);
	//volumeName.setFocusable(false);
	
	volumePath = (EditText) findViewById(R.id.volumePath);
	//volumePath.setFocusable(false);
	
	password = (EditText) findViewById(R.id.volumePassword);
	password.setTransformationMethod(PasswordTransformationMethod.getInstance());
	password.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); 
	
	onlyWifiCheckBox = ((CheckBox) findViewById(R.id.onlyWifi));
	removeAfterCheckBox = ((CheckBox) findViewById(R.id.removeAfter));
	localFolder = ((EditText) findViewById(R.id.localFolder));
	syncID = ((EditText) findViewById(R.id.syncID));
	syncID.setFocusable(false);
	
	
	spin1=(Spinner) findViewById(R.id.selectedRule);
	ArrayAdapter<String> adapter=new ArrayAdapter<String>(ConfigSyncActivity.this, android.R.layout.simple_spinner_item, rules);
	adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
	spin1.setAdapter(adapter);
	spin1.setOnTouchListener(this);
	spin1.setOnItemSelectedListener((OnItemSelectedListener) this);
	
	refresh(null);

	
}
 
Example 11
Project: lr_dialer   File: AbstractAQuery.java   View source code 5 votes vote down vote up
/**
 * Register a callback method for when an item is selected.
 *
 * @param listener The item selected listener.
 * @return self
 */
public T itemSelected(OnItemSelectedListener listener)
{
	if (view instanceof AdapterView)
	{
		AdapterView<?> alv = (AdapterView<?>) view;
		alv.setOnItemSelectedListener(listener);
	}
	return self();
}
 
Example 12
Project: ExoPlayerDemo   File: AbstractAQuery.java   View source code 5 votes vote down vote up
/**
 * Register a callback method for when an item is selected. 
 *
 * @param listener The item selected listener.
 * @return self
 */
public T itemSelected(OnItemSelectedListener listener){
	
	if(view instanceof AdapterView){		
		AdapterView<?> alv = (AdapterView<?>) view;
		alv.setOnItemSelectedListener(listener);		
	}
	
	return self();
	
}
 
Example 13
Project: DroidShows   File: DroidShows.java   View source code 5 votes vote down vote up
@SuppressLint("NewApi")
private void arrangeActionBar(Menu menu) {
	menu.findItem(TOGGLE_ARCHIVE_MENU_ITEM).setVisible(false);
	menu.findItem(LOG_MODE_ITEM).setVisible(false);
	menu.findItem(SEARCH_MENU_ITEM).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
	spinner = new Spinner(this);
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
		spinner.setPopupBackgroundResource(R.drawable.menu_dropdown_panel);
	spinner.setAdapter(new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1,
		new String[] {
			getString(R.string.layout_app_name),
			getString(R.string.archive),
			getString(R.string.menu_log),
		}));
	spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
		public void onItemSelected(AdapterView<?> parent, View v, int position, long id) {
			logMode = position == 2;
			showArchive = (position == 2 ? showArchive : position);
			if (logMode)
				clearFilter(null);
			getSeries();
		}
		public void onNothingSelected(AdapterView<?> arg0) {
		}
	});
	ActionBar actionBar = getActionBar();
	actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME);
	actionBar.setCustomView(spinner);
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
		actionBar.setIcon(R.drawable.actionbar);
}
 
Example 14
Project: Fabric-Example-App-Android   File: MoPubAdAdapterTest.java   View source code 5 votes vote down vote up
@Test
public void setOnItemSelectedListener_withAdPosition_shouldNotCallListener() {
    subject.setOnItemSelectedListener(mockListView, mockOnItemSelectedListener);

    ArgumentCaptor<OnItemSelectedListener> listenerCaptor =
            ArgumentCaptor.forClass(OnItemSelectedListener.class);
    verify(mockListView).setOnItemSelectedListener(listenerCaptor.capture());

    OnItemSelectedListener listener = listenerCaptor.getValue();
    listener.onItemSelected(mockListView, mockItemView, AD_POSITION, 0);

    verify(mockOnItemSelectedListener, never()).onItemSelected(
            any(AdapterView.class), any(View.class), anyInt(), anyInt());
}
 
Example 15
Project: Fabric-Example-App-Android   File: MoPubAdAdapterTest.java   View source code 5 votes vote down vote up
@Test
public void setOnItemSelectedListener_withNonAdPosition_shouldCallListener() {
    subject.setOnItemSelectedListener(mockListView, mockOnItemSelectedListener);

    ArgumentCaptor<OnItemSelectedListener> listenerCaptor =
            ArgumentCaptor.forClass(OnItemSelectedListener.class);
    verify(mockListView).setOnItemSelectedListener(listenerCaptor.capture());

    OnItemSelectedListener listener = listenerCaptor.getValue();
    listener.onItemSelected(mockListView, mockItemView, AD_POSITION + 1, 0);

    verify(mockOnItemSelectedListener).onItemSelected(
            mockListView, mockItemView, AD_POSITION, 0);
}
 
Example 16
Project: palette   File: ViewHelper.java   View source code 5 votes vote down vote up
/**
 * Register a callback method for when an item is selected.
 *
 * @param listener The item selected listener.
 * @return self
 */
public ViewHelper itemSelected(OnItemSelectedListener listener) {

    if (mView instanceof AdapterView) {
        AdapterView<?> alv = (AdapterView<?>) mView;
        alv.setOnItemSelectedListener(listener);
    }

    return this;

}
 
Example 17
Project: SyncFrameworkAndroid   File: SpinnerHelper.java   View source code 5 votes vote down vote up
public SpinnerHelper(Spinner spinner, int loaderID, ResourceCursorAdapter adapter, @LayoutRes int dropDownLayout, OnItemSelectedListener onSelected) {
    Spinner = spinner;
    mLoaderID = loaderID;
    Spinner.setOnItemSelectedListener(onSelected);
    Spinner.setAdapter(adapter);
    adapter.setDropDownViewResource(dropDownLayout);

}
 
Example 18
Project: CardUI   File: GridActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        // Intialize and set the Action Bar to Holo Blue
        ActionBar actionBar = getActionBar();
        actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#33b5e5" )));
        
        GridView grid = (GridView) findViewById(R.id.myGrid);
         rowItems = new ArrayList<RowItem>();
         
        String[] titles = {"Movie1","Movie2","Movie3","Movie4","Movie5","Movie6","Movie7","Movie8"};
        String[] descriptions = {"First Movie","Second movie","Third Movie","Fourth Movie","Fifth Movie",
                        "Sixth Movie","Seventh Movie","Eighth Movie"};
        //Populate the List
        for (int i = 0; i < titles.length; i++) {
            RowItem item = new RowItem(images[i], titles[i], descriptions[i]);
            rowItems.add(item);
        }

        // Set the adapter on the ListView
        LazyAdapter adapter = new LazyAdapter(getApplicationContext(), R.layout.grid_row, rowItems);
        grid.setAdapter(adapter);
        
        grid.setOnItemSelectedListener(new OnItemSelectedListener() {

                        @Override
                        public void onItemSelected(AdapterView<?> arg0, View arg1,
                                        int arg2, long arg3) {
                                // TODO Auto-generated method stub
                                
                        }

                        
                });
}
 
Example 19
Project: Wabbit-Messenger---android-client   File: ItemManaged.java   View source code 5 votes vote down vote up
void setOnItemSelectedListener(OnItemSelectedListener l) {
    if (mInstallingManager) {
        return;
    }

    mOnItemSelectedListener = l;
}
 
Example 20
Project: Wabbit-Messenger---android-client   File: ItemManager.java   View source code 5 votes vote down vote up
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
    if (mScrollState != OnScrollListener.SCROLL_STATE_IDLE) {
        mScrollState = OnScrollListener.SCROLL_STATE_IDLE;
        postUpdateItems();
    }

    final OnItemSelectedListener l = mManaged.getOnItemSelectedListener();
    if (l != null) {
        l.onItemSelected(adapterView, view, position, id);
    }
}
 
Example 21
Project: Wabbit-Messenger---android-client   File: ItemManager.java   View source code 5 votes vote down vote up
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
    final OnItemSelectedListener l = mManaged.getOnItemSelectedListener();
    if (l != null) {
        l.onNothingSelected(adapterView);
    }
}
 
Example 22
Project: EasyQuranMemorizer   File: MyMediaPlayer.java   View source code 5 votes vote down vote up
private void initializeReciterSpinner()

	{

		ReciterDataManger manager = new ReciterDataManger(
				getApplicationContext());
		downloadedReciterList = manager.getDownloadedReciterList(surah);

		// setting reciter spinner list
		ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_spinner_item, downloadedReciterList);
		dataAdapter
				.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		reciterSpinner.setAdapter(dataAdapter);
		reciterSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

			@Override
			public void onItemSelected(AdapterView<?> parent, View view,
					int position, long id) {

				selectedAuthorName = downloadedReciterList.get(position);
				// if (selectedAuthorName != CONSTANT.AUDIO_NOT_FOUND) {
				// resetVerse();
				// play();
				// }
				resetVerse();
				play();
			}

			@Override
			public void onNothingSelected(AdapterView<?> arg0) {

			}

		});

	}
 
Example 23
Project: NeXT_pyp   File: AbstractAQuery.java   View source code 5 votes vote down vote up
/**
 * Register a callback method for when an item is selected. 
 *
 * @param listener The item selected listener.
 * @return self
 */
public T itemSelected(OnItemSelectedListener listener){
	
	if(view instanceof AdapterView){		
		AdapterView<?> alv = (AdapterView<?>) view;
		alv.setOnItemSelectedListener(listener);		
	}
	
	return self();
	
}
 
Example 24
Project: NeXT_pyp   File: AbstractAQuery.java   View source code 5 votes vote down vote up
/**
 * Register a callback method for when an item is selected.
 * 
 * @param listener
 *            The item selected listener.
 * @return self
 */
public T itemSelected(OnItemSelectedListener listener) {

	if (view instanceof AdapterView) {
		AdapterView<?> alv = (AdapterView<?>) view;
		alv.setOnItemSelectedListener(listener);
	}

	return self();

}
 
Example 25
Project: NeXT_pyp   File: AbstractAQuery.java   View source code 5 votes vote down vote up
/**
 * Register a callback method for when an item is selected.
 * 
 * @param listener
 *            The item selected listener.
 * @return self
 */
public T itemSelected(OnItemSelectedListener listener) {

	if (view instanceof AdapterView) {
		AdapterView<?> alv = (AdapterView<?>) view;
		alv.setOnItemSelectedListener(listener);
	}

	return self();

}
 
Example 26
Project: Android-Project-Manager   File: SpinnerUtil.java   View source code 5 votes vote down vote up
public static ArrayAdapter<CharSequence> setCustomSpinnerAdapter (final Context context, final Fragment fragment, 
		final FragmentManager fragmentManager, String spinnerFileName, Spinner spinner, boolean sort) {
	FileOperations fO = new FileOperations(context);
	
	String spinnerItems = fO.readFile(spinnerFileName);
	ArrayList<String> spinnerItemsArray = fO.convertToStringList(spinnerItems);
	if(sort)
		Collections.sort(spinnerItemsArray.subList(0, spinnerItemsArray.size()));
	spinnerItemsArray.add("Custom...");
	
	//Set the adapter for the status spinner 
	final ArrayAdapter<CharSequence> spinnerAdapter = new ArrayAdapter<CharSequence>(context, android.R.layout.simple_spinner_item);
	spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
	spinnerAdapter.addAll(spinnerItemsArray);
	spinner.setAdapter(spinnerAdapter);
	
	spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
		@Override
		public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
			if( "Custom...".equals((String) spinnerAdapter.getItem(position))) {
				DialogFragment customStatusDialog = new CustomStatus();
				customStatusDialog.setTargetFragment(fragment, 0);
				customStatusDialog.show(fragmentManager, "Custom Status Dialog");
			}
		}
		@Override
		public void onNothingSelected(AdapterView<?> arg0) { }
	});
	
	return spinnerAdapter;
}
 
Example 27
Project: CardUI   File: GridActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        // Intialize and set the Action Bar to Holo Blue
        ActionBar actionBar = getActionBar();
        actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#33b5e5" )));
        
        GridView grid = (GridView) findViewById(R.id.myGrid);
         rowItems = new ArrayList<RowItem>();
         
        String[] titles = {"Movie1","Movie2","Movie3","Movie4","Movie5","Movie6","Movie7","Movie8"};
        String[] descriptions = {"First Movie","Second movie","Third Movie","Fourth Movie","Fifth Movie",
                        "Sixth Movie","Seventh Movie","Eighth Movie"};
        //Populate the List
        for (int i = 0; i < titles.length; i++) {
            RowItem item = new RowItem(images[i], titles[i], descriptions[i]);
            rowItems.add(item);
        }

        // Set the adapter on the ListView
        LazyAdapter adapter = new LazyAdapter(getApplicationContext(), R.layout.grid_row, rowItems);
        grid.setAdapter(adapter);
        
        grid.setOnItemSelectedListener(new OnItemSelectedListener() {

                        @Override
                        public void onItemSelected(AdapterView<?> arg0, View arg1,
                                        int arg2, long arg3) {
                                // TODO Auto-generated method stub
                                
                        }

                        
                });
}
 
Example 28
Project: jukefox   File: SearchActivity.java   View source code 5 votes vote down vote up
private void registerSpinner(int selectedPos) {
		searchInSelectionSpinner = (Spinner)findViewById(R.id.searchInSelectionSpinner);
		searchInSelectionSpinner.setSelection(selectedPos); // title
		searchInSelectionSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

			@Override
			public void onItemSelected(AdapterView<?> parent, View view,
					int pos, long id) {
				search();
			}

			@Override
			public void onNothingSelected(AdapterView<?> arg0) {
				// TODO: nothing to do (?)
			}
		});
//		searchInArtists = (RadioButton) findViewById(R.id.searchInArtists);
//		searchInAlbums = (RadioButton) findViewById(R.id.searchInAlbums);
//		searchInFamousArtists = (RadioButton) findViewById(R.id.searchInSimilarArtists);
//		searchInTitles = (RadioButton) findViewById(R.id.searchInTitles);
//		RadioGroup radioGroup = (RadioGroup) findViewById(R.id.searchCriterion);
//		radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
//
//			@Override
//			public void onCheckedChanged(RadioGroup group, int checkedId) {
//				search();
//			}
//		});
	}
 
Example 29
Project: triples   File: StatisticsSelectorView.java   View source code 5 votes vote down vote up
private void initSpinner() {
  mSpinner = (Spinner) findViewById(R.id.period_spinner);

  ArrayAdapter<CharSequence> adapter =
      new ArrayAdapter<CharSequence>(getContext(), android.R.layout.simple_spinner_item);
  adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  initPeriodsMap();
  for (String key : PERIODS.keySet()) {
    adapter.add(key);
  }
  mSpinner.setAdapter(adapter);

  mSpinner.setOnItemSelectedListener(
      new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
          String string = (String) parent.getItemAtPosition(pos);
          mCurrentPeriod = PERIODS.get(string);
          if (mOnPeriodChangeListener != null) {
            mOnPeriodChangeListener.onPeriodChange(mCurrentPeriod);
          }
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {}
      });
  mCurrentPeriod = PERIODS.get(mSpinner.getSelectedItem().toString());
}
 
Example 30
Project: gundog-engine   File: OnlineGameLayout.java   View source code 5 votes vote down vote up
private Spinner generateSpinner(Context context, OnItemSelectedListener listener, int description, int[] choices) {
	String[] mStrings = new String[choices.length];
	Resources resources = context.getResources();
	for (int i = 0; i < mStrings.length; i++) {
		mStrings[i] = resources.getString(description) + ": " + resources.getString(choices[i]).toUpperCase();
	}

	Spinner speedSpinner = new Spinner(context);
	ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, android.R.layout.simple_spinner_item, mStrings);
	adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
	speedSpinner.setAdapter(adapter);
	speedSpinner.setOnItemSelectedListener(listener);
	return speedSpinner;
}
 
Example 31
Project: gundog-engine   File: NewGameLayout.java   View source code 5 votes vote down vote up
private Spinner generateSpinner(Context context, OnItemSelectedListener listener, int description, int[] choices) {
	String[] mStrings = new String[choices.length];
	Resources resources = context.getResources();
	for (int i = 0; i < mStrings.length; i++) {
		mStrings[i] = resources.getString(description) + ": " + resources.getString(choices[i]).toUpperCase();
	}

	Spinner speedSpinner = new Spinner(context);
	ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, android.R.layout.simple_spinner_item, mStrings);
	adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
	speedSpinner.setAdapter(adapter);
	speedSpinner.setOnItemSelectedListener(listener);
	return speedSpinner;
}
 
Example 32
Project: gundog-engine   File: CampaignLevelLayout.java   View source code 5 votes vote down vote up
private Spinner generateSpinner(Context context, OnItemSelectedListener listener, int description, int[] choices) {
	String[] mStrings = new String[choices.length];
	Resources resources = context.getResources();
	for (int i = 0; i < mStrings.length; i++) {
		mStrings[i] = resources.getString(description) + ": " + resources.getString(choices[i]).toUpperCase();
	}

	Spinner speedSpinner = new Spinner(context);
	ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, android.R.layout.simple_spinner_item, mStrings);
	adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
	speedSpinner.setAdapter(adapter);
	speedSpinner.setOnItemSelectedListener(listener);
	return speedSpinner;
}
 
Example 33
Project: BeeFramework_Android   File: AbstractAQuery.java   View source code 5 votes vote down vote up
/**
 * Register a callback method for when an item is selected. 
 *
 * @param listener The item selected listener.
 * @return self
 */
public T itemSelected(OnItemSelectedListener listener){
	
	if(view instanceof AdapterView){		
		AdapterView<?> alv = (AdapterView<?>) view;
		alv.setOnItemSelectedListener(listener);		
	}
	
	return self();
	
}
 
Example 34
Project: q-mail   File: AccountSetupIncoming.java   View source code 4 votes vote down vote up
/**
 * This is invoked only when the user makes changes to a widget, not when
 * widgets are changed programmatically.  (The logic is simpler when you know
 * that this is the last thing called after an input change.)
 */
private void validateFields() {
    AuthType authType = getSelectedAuthType();
    boolean isAuthTypeExternal = (AuthType.EXTERNAL == authType);

    ConnectionSecurity connectionSecurity = getSelectedSecurity();
    boolean hasConnectionSecurity = (connectionSecurity != ConnectionSecurity.NONE);

    if (isAuthTypeExternal && !hasConnectionSecurity) {

        // Notify user of an invalid combination of AuthType.EXTERNAL & ConnectionSecurity.NONE
        String toastText = getString(R.string.account_setup_incoming_invalid_setting_combo_notice,
                getString(R.string.account_setup_incoming_auth_type_label),
                AuthType.EXTERNAL.toString(),
                getString(R.string.account_setup_incoming_security_label),
                ConnectionSecurity.NONE.toString());
        Toast.makeText(this, toastText, Toast.LENGTH_LONG).show();

        // Reset the views back to their previous settings without recursing through here again
        OnItemSelectedListener onItemSelectedListener = mAuthTypeView.getOnItemSelectedListener();
        mAuthTypeView.setOnItemSelectedListener(null);
        mAuthTypeView.setSelection(mCurrentAuthTypeViewPosition, false);
        mAuthTypeView.setOnItemSelectedListener(onItemSelectedListener);
        updateViewFromAuthType();

        onItemSelectedListener = mSecurityTypeView.getOnItemSelectedListener();
        mSecurityTypeView.setOnItemSelectedListener(null);
        mSecurityTypeView.setSelection(mCurrentSecurityTypeViewPosition, false);
        mSecurityTypeView.setOnItemSelectedListener(onItemSelectedListener);
        updateAuthPlainTextFromSecurityType(getSelectedSecurity());

        mPortView.removeTextChangedListener(validationTextWatcher);
        mPortView.setText(mCurrentPortViewSetting);
        mPortView.addTextChangedListener(validationTextWatcher);

        authType = getSelectedAuthType();
        isAuthTypeExternal = (AuthType.EXTERNAL == authType);

        connectionSecurity = getSelectedSecurity();
        hasConnectionSecurity = (connectionSecurity != ConnectionSecurity.NONE);
    } else {
        mCurrentAuthTypeViewPosition = mAuthTypeView.getSelectedItemPosition();
        mCurrentSecurityTypeViewPosition = mSecurityTypeView.getSelectedItemPosition();
        mCurrentPortViewSetting = mPortView.getText().toString();
    }

    boolean hasValidCertificateAlias = mClientCertificateSpinner.getAlias() != null;
    boolean hasValidUserName = Utility.requiredFieldValid(mUsernameView);

    boolean hasValidPasswordSettings = hasValidUserName
            && !isAuthTypeExternal
            && Utility.requiredFieldValid(mPasswordView);

    boolean hasValidExternalAuthSettings = hasValidUserName
            && isAuthTypeExternal
            && hasConnectionSecurity
            && hasValidCertificateAlias;

    mNextButton.setEnabled(Utility.domainFieldValid(mServerView)
            && Utility.requiredFieldValid(mPortView)
            && (hasValidPasswordSettings || hasValidExternalAuthSettings));
    Utility.setCompoundDrawablesAlpha(mNextButton, mNextButton.isEnabled() ? 255 : 128);
}
 
Example 35
Project: q-mail   File: AccountSetupOutgoing.java   View source code 4 votes vote down vote up
/**
 * This is invoked only when the user makes changes to a widget, not when
 * widgets are changed programmatically.  (The logic is simpler when you know
 * that this is the last thing called after an input change.)
 */
private void validateFields() {
    AuthType authType = getSelectedAuthType();
    boolean isAuthTypeExternal = (AuthType.EXTERNAL == authType);

    ConnectionSecurity connectionSecurity = getSelectedSecurity();
    boolean hasConnectionSecurity = (connectionSecurity != ConnectionSecurity.NONE);

    if (isAuthTypeExternal && !hasConnectionSecurity) {

        // Notify user of an invalid combination of AuthType.EXTERNAL & ConnectionSecurity.NONE
        String toastText = getString(R.string.account_setup_outgoing_invalid_setting_combo_notice,
                getString(R.string.account_setup_incoming_auth_type_label),
                AuthType.EXTERNAL.toString(),
                getString(R.string.account_setup_incoming_security_label),
                ConnectionSecurity.NONE.toString());
        Toast.makeText(this, toastText, Toast.LENGTH_LONG).show();

        // Reset the views back to their previous settings without recursing through here again
        OnItemSelectedListener onItemSelectedListener = mAuthTypeView.getOnItemSelectedListener();
        mAuthTypeView.setOnItemSelectedListener(null);
        mAuthTypeView.setSelection(mCurrentAuthTypeViewPosition, false);
        mAuthTypeView.setOnItemSelectedListener(onItemSelectedListener);
        updateViewFromAuthType();

        onItemSelectedListener = mSecurityTypeView.getOnItemSelectedListener();
        mSecurityTypeView.setOnItemSelectedListener(null);
        mSecurityTypeView.setSelection(mCurrentSecurityTypeViewPosition, false);
        mSecurityTypeView.setOnItemSelectedListener(onItemSelectedListener);
        updateAuthPlainTextFromSecurityType(getSelectedSecurity());

        mPortView.removeTextChangedListener(validationTextWatcher);
        mPortView.setText(mCurrentPortViewSetting);
        mPortView.addTextChangedListener(validationTextWatcher);

        authType = getSelectedAuthType();
        isAuthTypeExternal = (AuthType.EXTERNAL == authType);

        connectionSecurity = getSelectedSecurity();
        hasConnectionSecurity = (connectionSecurity != ConnectionSecurity.NONE);
    } else {
        mCurrentAuthTypeViewPosition = mAuthTypeView.getSelectedItemPosition();
        mCurrentSecurityTypeViewPosition = mSecurityTypeView.getSelectedItemPosition();
        mCurrentPortViewSetting = mPortView.getText().toString();
    }

    boolean hasValidCertificateAlias = mClientCertificateSpinner.getAlias() != null;
    boolean hasValidUserName = Utility.requiredFieldValid(mUsernameView);

    boolean hasValidPasswordSettings = hasValidUserName
            && !isAuthTypeExternal
            && Utility.requiredFieldValid(mPasswordView);

    boolean hasValidExternalAuthSettings = hasValidUserName
            && isAuthTypeExternal
            && hasConnectionSecurity
            && hasValidCertificateAlias;

    mNextButton
            .setEnabled(Utility.domainFieldValid(mServerView)
                    && Utility.requiredFieldValid(mPortView)
                    && (!mRequireLoginView.isChecked()
                            || hasValidPasswordSettings || hasValidExternalAuthSettings));
    Utility.setCompoundDrawablesAlpha(mNextButton, mNextButton.isEnabled() ? 255 : 128);
}
 
Example 36
Project: GitHub   File: GridPickerView.java   View source code 4 votes vote down vote up
public void setOnItemSelectedListener(OnItemSelectedListener onItemSelectedListener) {
	this.onItemSelectedListener = onItemSelectedListener;
}
 
Example 37
Project: GitHub   File: GridPickerAdapter.java   View source code 4 votes vote down vote up
public void setOnItemSelectedListener(OnItemSelectedListener onItemSelectedListener) {
	this.onItemSelectedListener = onItemSelectedListener;
}
 
Example 38
Project: GitHub   File: GridPickerView.java   View source code 4 votes vote down vote up
public void setOnItemSelectedListener(OnItemSelectedListener onItemSelectedListener) {
	this.onItemSelectedListener = onItemSelectedListener;
}
 
Example 39
Project: GitHub   File: GridPickerAdapter.java   View source code 4 votes vote down vote up
public void setOnItemSelectedListener(OnItemSelectedListener onItemSelectedListener) {
	this.onItemSelectedListener = onItemSelectedListener;
}
 
Example 40
Project: APIJSON-Android-RxJava   File: GridPickerView.java   View source code 4 votes vote down vote up
public void setOnItemSelectedListener(OnItemSelectedListener onItemSelectedListener) {
	this.onItemSelectedListener = onItemSelectedListener;
}