Java Code Examples for android.widget.Spinner#getContext()

The following examples show how to use android.widget.Spinner#getContext() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TreeSync.java    From HtmlView2 with Apache License 2.0 6 votes vote down vote up
static void syncSelect(Spinner spinner, Hv2DomElement element) {
  ArrayAdapter<String> options = new ArrayAdapter<String>(spinner.getContext(),
      android.R.layout.simple_spinner_dropdown_item);
  spinner.setAdapter(options);

  Hv2DomElement child = element.getFirstElementChild();
  while (child != null) {
    if (child.getLocalName().equals("option")) {
      boolean selected = child.getAttribute("selected") != null;
      String content = child.getTextContent();
      options.add(content);
      if (child.getAttribute("selected") != null) {
        spinner.setSelection(options.getCount() - 1);
      }
      child = child.getNextElementSibling();
    }
  }
}
 
Example 2
Source File: BitmapAnimationCacheSelectorConfigurator.java    From fresco with MIT License 6 votes vote down vote up
public BitmapAnimationCacheSelectorConfigurator(
    Spinner spinner,
    BitmapFrameCacheChangedListener bitmapFrameCacheChangedListener,
    BitmapFrameCache.FrameCacheListener frameCacheListener) {
  mSpinner = spinner;
  mBitmapFrameCacheChangedListener = bitmapFrameCacheChangedListener;
  mFrameCacheListener = frameCacheListener;

  mContext = mSpinner.getContext();
  mArrayAdapter = new ArrayAdapter<>(spinner.getContext(), android.R.layout.simple_spinner_item);
  mArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  mSpinner.setAdapter(mArrayAdapter);

  addSampleBackends();
  setupSelector();
}
 
Example 3
Source File: SampleAnimationBackendConfigurator.java    From fresco with MIT License 5 votes vote down vote up
public SampleAnimationBackendConfigurator(
    Spinner spinner, BackendChangedListener backendChangedListener) {
  mSpinner = spinner;
  mBackendChangedListener = backendChangedListener;

  mContext = mSpinner.getContext();
  mArrayAdapter = new ArrayAdapter<>(spinner.getContext(), android.R.layout.simple_spinner_item);
  mArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  mSpinner.setAdapter(mArrayAdapter);

  addSampleBackends();
  setupBackendSelector();
}
 
Example 4
Source File: DiscussionPostsSpinnerAdapter.java    From edx-app-android with Apache License 2.0 5 votes vote down vote up
public DiscussionPostsSpinnerAdapter(@NonNull Spinner spinner,
        @NonNull TextResourceProvider[] textResourceProviders,
        @NonNull IconDrawableFactory iconDrawableFactory) {
    super(spinner.getContext(), R.layout.row_discussion_thread_dropdown, textResourceProviders);
    this.iconDrawableFactory = iconDrawableFactory;
    this.spinner = spinner;
}
 
Example 5
Source File: ExtAuthHelper.java    From bitmask_android with GNU General Public License v3.0 5 votes vote down vote up
public static void setExternalAuthProviderSpinnerList(Spinner spinner, String selectedApp) {
    Context c = spinner.getContext();
    final PackageManager pm = c.getPackageManager();
    ArrayList<ExternalAuthProvider> extProviders = getExternalAuthProviderList(c);

    int selectedPos = -1;

    if (extProviders.size() ==0)
    {
        selectedApp = "";
        ExternalAuthProvider noauthprovider = new ExternalAuthProvider();
        noauthprovider.label = "No external auth provider found";
        noauthprovider.packageName = selectedApp;
        noauthprovider.configurable = false;
        extProviders.add(noauthprovider);
    }


    for (int i = 0; i < extProviders.size(); i++) {
        if (extProviders.get(i).packageName.equals(selectedApp))
            selectedPos = i;
    }
    SpinnerAdapter extAppAdapter = new ArrayAdapter<ExternalAuthProvider>(c, android.R.layout.simple_spinner_item, android.R.id.text1, extProviders);
    spinner.setAdapter(extAppAdapter);
    if (selectedPos != -1)
        spinner.setSelection(selectedPos);
}
 
Example 6
Source File: GalleryFragment.java    From CameraV with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
	super.onCreateOptionsMenu(menu, inflater);
	inflater.inflate(R.menu.activity_home_gallery, menu);

	MenuItem menuFilter = menu.findItem(R.id.menu_filter);
	Spinner spinner = (Spinner) menuFilter.getActionView();
	GalleryFilterAdapter spinnerAdapter = new GalleryFilterAdapter(spinner.getContext(), this.getResources().getTextArray(R.array.filter_options));
	spinner.setAdapter(spinnerAdapter);
	spinner.setOnItemSelectedListener(this);
	
	mMenuItemBatchOperations = menu.findItem(R.id.menu_select);
	
	miDropbox = menu.findItem(R.id.menu_remote_access_dropbox);
	DropboxSyncManager dsm = DropboxSyncManager.getInstance(a);
	if (dsm != null && dsm.isSyncing())
		miDropbox.setChecked(true);
	
	ActionBar actionBar = getActivity().getActionBar();
	actionBar.setDisplayShowTitleEnabled(true);
	actionBar.setTitle(R.string.home_gallery_title);
	actionBar.setDisplayShowHomeEnabled(true);
	actionBar.setDisplayHomeAsUpEnabled(false);
	actionBar.setHomeButtonEnabled(true);
	actionBar.setLogo(this.getResources().getDrawable(
			R.drawable.ic_action_up));
	actionBar.setDisplayUseLogoEnabled(true);
	actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
}
 
Example 7
Source File: LanguageFilterSpinnerHelper.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
LanguageFilterSpinnerHelper(Spinner spinner) {
  this.spinner = spinner;
  this.resources = spinner.getResources();
  this.context = spinner.getContext();
  languageFilterHelper = new LanguageFilterHelper(resources);
}
 
Example 8
Source File: DiscussionPostsSpinnerAdapter.java    From edx-app-android with Apache License 2.0 4 votes vote down vote up
public DiscussionPostsSpinnerAdapter(@NonNull Spinner spinner,
        @NonNull TextResourceProvider[] textResourceProviders,
        @NonNull Icon icon) {
    this(spinner, textResourceProviders,
            new IconDrawableFactoryImpl(spinner.getContext(), icon));
}