Java Code Examples for android.widget.ArrayAdapter#createFromResource()

The following examples show how to use android.widget.ArrayAdapter#createFromResource() . 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: ConfigEditorFragment.java    From SSLSocks with MIT License 6 votes vote down vote up
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	Activity act = getActivity();
	if (act == null) return;

	Spinner spinner = view.findViewById(R.id.spinner);
	ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(act,
			R.array.files_array, android.R.layout.simple_spinner_item);
	adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
	spinner.setAdapter(adapter);
	spinner.setOnItemSelectedListener(this);

	currentView = new WeakReference<>(view);

	openFile();
}
 
Example 2
Source File: AnyPathActivity.java    From android-pdk with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_any_path);
    setTitle("Get Path..");

    pathText = (EditText) findViewById(R.id.path_edittext);
    fieldsText = (EditText) findViewById(R.id.fields_edittext);
    responseView = (TextView) findViewById(R.id.path_response_view);
    responseView.setMovementMethod(new ScrollingMovementMethod());
    getButton = (Button) findViewById(R.id.get_button);
    getButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onGet();
        }
    });

    spinner = (Spinner) findViewById(R.id.spinner);
    spinner.setOnItemSelectedListener(this);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
        R.array.paths_array, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
}
 
Example 3
Source File: DFPCustomTargetingFragment.java    From android-ads with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    sportsSpinner = getView().findViewById(R.id.customtargeting_spn_sport);
    loadButton = getView().findViewById(R.id.customtargeting_btn_loadad);
    adView = getView().findViewById(R.id.customtargeting_av_main);

    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getView().getContext(),
            R.array.customtargeting_sports, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    sportsSpinner.setAdapter(adapter);

    loadButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            PublisherAdRequest adRequest = new PublisherAdRequest.Builder()
                    .addCustomTargeting(getString(R.string.customtargeting_key),
                            (String) sportsSpinner.getSelectedItem())
                    .build();

            adView.loadAd(adRequest);
        }
    });
}
 
Example 4
Source File: DFPCustomTargetingFragment.java    From googleads-mobile-android-examples with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    sportsSpinner = getView().findViewById(R.id.customtargeting_spn_sport);
    loadButton = getView().findViewById(R.id.customtargeting_btn_loadad);
    adView = getView().findViewById(R.id.customtargeting_av_main);

    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getView().getContext(),
            R.array.customtargeting_sports, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    sportsSpinner.setAdapter(adapter);

    loadButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            PublisherAdRequest adRequest = new PublisherAdRequest.Builder()
                    .addCustomTargeting(getString(R.string.customtargeting_key),
                            (String) sportsSpinner.getSelectedItem())
                    .build();

            adView.loadAd(adRequest);
        }
    });
}
 
Example 5
Source File: SimpleActivity.java    From android-test with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.simple_activity);

  Spinner spinner = (Spinner) findViewById(R.id.spinner_simple);
  ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
      R.array.spinner_array, android.R.layout.simple_spinner_item);
  adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  spinner.setAdapter(adapter);
  spinner.setOnItemSelectedListener(this);
}
 
Example 6
Source File: MainActivity.java    From discreet-app-rate with Apache License 2.0 5 votes vote down vote up
private void manageViews() {
    buttonBar = (LinearLayout) findViewById(R.id.button_bar);

    okButton = (Button) findViewById(R.id.ok_button);
    currentCount = (TextView) findViewById(R.id.curent_count);
    hasBeenClicked = (TextView) findViewById(R.id.has_been_clicked);
    isElpased = (TextView) findViewById(R.id.is_elapsed);
    lastCrash = (TextView) findViewById(R.id.last_crash);
    monitoredTime = (TextView) findViewById(R.id.monitored_time);
    initialCount = (EditText) findViewById(R.id.initial_count);
    text = (EditText) findViewById(R.id.text);
    delay = (EditText) findViewById(R.id.delay);
    retryPolicy = (Spinner) findViewById(R.id.retry_policy);
    theme = (Spinner) findViewById(R.id.theme);
    actionSpinner = (Spinner) findViewById(R.id.action_chooser);
    installTime = (EditText) findViewById(R.id.install_time);
    pauseAfterCrash = (EditText) findViewById(R.id.pause_after_crash);
    minimumMonitoringTime = (EditText) findViewById(R.id.minimum_monitoring_time);
    minimumInterval = (EditText) findViewById(R.id.minimum_interval);
    onTop = (CheckBox) findViewById(R.id.on_top);
    useCustomView = (CheckBox) findViewById(R.id.use_custom_view);


    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
            R.array.retry_policies, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    retryPolicy.setAdapter(adapter);

    ArrayAdapter<CharSequence> adapterTheme = ArrayAdapter.createFromResource(this,
            R.array.themes, android.R.layout.simple_spinner_item);
    adapterTheme.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    theme.setAdapter(adapterTheme);

    ArrayAdapter<CharSequence> actionAdapter = ArrayAdapter.createFromResource(this,
            R.array.actions, android.R.layout.simple_spinner_item);
    actionAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    actionSpinner.setAdapter(actionAdapter);

}
 
Example 7
Source File: TextureParametersView.java    From ShaderEditor with MIT License 5 votes vote down vote up
private void initSpinner(Spinner spinner, int namesId) {
	ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
			spinner.getContext(),
			namesId,
			android.R.layout.simple_spinner_item);
	adapter.setDropDownViewResource(
			android.R.layout.simple_spinner_dropdown_item);
	spinner.setAdapter(adapter);
}
 
Example 8
Source File: AddBugFragment.java    From Travel-Mate with MIT License 5 votes vote down vote up
private void setupSpinner() {
    ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource(getActivity(),
            R.array.bug_types, android.R.layout.simple_spinner_item);
    mBugTypeSpinner.setOnItemSelectedListener(this);
    spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mBugTypeSpinner.setAdapter(spinnerAdapter);
}
 
Example 9
Source File: CallIntentsActivity.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.main);
	spinner = (Spinner) findViewById(R.id.spinner);
	ArrayAdapter adapter = ArrayAdapter.createFromResource(this,
			R.array.intents, android.R.layout.simple_spinner_item);
	adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
	spinner.setAdapter(adapter);
}
 
Example 10
Source File: SamplePugNotification.java    From Pugnotification with Apache License 2.0 5 votes vote down vote up
private void loadInfoComponents() {
    this.mEdtTitle = (EditText) findViewById(R.id.edt_title);
    this.mEdtMessage = (EditText) findViewById(R.id.edt_message);
    this.mEdtBigText = (EditText) findViewById(R.id.edt_bigtext);
    this.mEdtUrl = (EditText) findViewById(R.id.edt_url);
    this.mBtnNotifySimple = (Button) findViewById(R.id.btn_notify_simple);
    this.mBtnNotifyCustom = (Button) findViewById(R.id.btn_notify_custom);
    this.mSpnType = (Spinner) findViewById(R.id.spn_notification_type);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
            R.array.pugnotification_notification_types, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    this.mSpnType.setAdapter(adapter);

    this.mContentBigText = (RelativeLayout) findViewById(R.id.content_bigtext);
}
 
Example 11
Source File: AudioFragment.java    From walt with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    logger = SimpleLogger.getInstance(getContext());

    audioTest = new AudioTest(getActivity());
    audioTest.setTestStateListener(this);

    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_audio, container, false);
    textView = (TextView) view.findViewById(R.id.txt_box_audio);
    textView.setMovementMethod(new ScrollingMovementMethod());
    startButton = view.findViewById(R.id.button_start_audio);
    stopButton = view.findViewById(R.id.button_stop_audio);
    chartLayout = view.findViewById(R.id.chart_layout);
    chart = (LineChart) view.findViewById(R.id.chart);
    latencyChart = (HistogramChart) view.findViewById(R.id.latency_chart);

    view.findViewById(R.id.button_close_chart).setOnClickListener(this);
    enableButtons();

    // Configure the audio mode spinner
    modeSpinner = (Spinner) view.findViewById(R.id.spinner_audio_mode);
    ArrayAdapter<CharSequence> modeAdapter = ArrayAdapter.createFromResource(getContext(),
            R.array.audio_mode_array, android.R.layout.simple_spinner_item);
    modeAdapter.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item);
    modeSpinner.setAdapter(modeAdapter);

    return view;
}
 
Example 12
Source File: CallbackLessAutoCompleteSignInActivity.java    From android-AutofillFramework with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.login_with_autocomplete_activity);

    TextView title = findViewById(R.id.standard_login_header);
    title.setText(R.string.navigation_button_anti_pattern_callbackless_autocomplete_login_label);

    InfoButton info = findViewById(R.id.imageButton);
    info.setInfoText(getString(R.string.anti_pattern_callbackless_autocomplete_login_info));


    mLoginButton = findViewById(R.id.login);
    mClearButton = findViewById(R.id.clear);
    mUsernameAutoCompleteField = findViewById(R.id.usernameField);
    mPasswordField = findViewById(R.id.passwordField);
    mLoginButton.setOnClickListener((v) -> login());
    mClearButton.setOnClickListener((v) -> {
        AutofillManager afm = getSystemService(AutofillManager.class);
        if (afm != null) {
            afm.cancel();
        }
        resetFields();
    });
    ArrayAdapter<CharSequence> mockAutocompleteAdapter = ArrayAdapter.createFromResource
            (this, R.array.mock_autocomplete_sign_in_suggestions,
                    android.R.layout.simple_dropdown_item_1line);
    mUsernameAutoCompleteField.setAdapter(mockAutocompleteAdapter);
    mUsernameAutoCompleteField.setThreshold(1);

    // Show it right away
    mUsernameAutoCompleteField.setOnFocusChangeListener((v, hasFocus) -> {
        if (hasFocus) {
            mUsernameAutoCompleteField.showDropDown();
        }
    });
}
 
Example 13
Source File: WifiConfigCreationDialog.java    From android-testdpc with Apache License 2.0 5 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    LayoutInflater inflater = getActivity().getLayoutInflater();

    View dialogView = inflater.inflate(R.layout.wifi_config_dialog, null);
    mPasswordView = dialogView.findViewById(R.id.password_layout);
    mSsidText = (EditText) dialogView.findViewById(R.id.ssid);
    mSsidText.addTextChangedListener(this);
    mPasswordText = (EditText) dialogView.findViewById(R.id.password);
    mPasswordText.addTextChangedListener(this);

    mSecurityChoicesSpinner = (Spinner) dialogView.findViewById(R.id.security);
    mSecurityChoicesSpinner.setOnItemSelectedListener(this);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(),
            R.array.wifi_security_choices, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mSecurityChoicesSpinner.setAdapter(adapter);
    initialize();

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
            .setTitle(R.string.add_network)
            .setView(dialogView)
            // Listener for save button will be set in onStart().
            .setPositiveButton(R.string.wifi_save, null)
            .setNegativeButton(R.string.wifi_cancel, null);

    return builder.create();
}
 
Example 14
Source File: BasicMapzenActivity.java    From android with Apache License 2.0 5 votes vote down vote up
@Override protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_spinner);

  Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);
  getSupportActionBar().setDisplayShowTitleEnabled(false);

  Spinner spinner = (Spinner) findViewById(R.id.spinner);
  ArrayAdapter<CharSequence> adapter =
      ArrayAdapter.createFromResource(this, R.array.enabled_disabled_array,
          R.layout.simple_spinner_item);
  adapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item);
  spinner.setAdapter(adapter);
  spinner.setOnItemSelectedListener(this);

  final boolean enabled = (savedInstanceState == null ||
      savedInstanceState.getBoolean(KEY_LOCATION_ENABLED));

  final long millis = System.currentTimeMillis();

  final MapFragment mapFragment =
      (MapFragment) getSupportFragmentManager().findFragmentById(R.id.fragment);
  mapFragment.getMapAsync(new OnMapReadyCallback() {
    @Override public void onMapReady(MapzenMap map) {
      long now = System.currentTimeMillis();
      long elapsedTime = now - millis;
      Log.d(TAG, "onMapReady [" + elapsedTime + "] millis");
      BasicMapzenActivity.this.map = map;
      configureMap(enabled);
    }
  });
}
 
Example 15
Source File: PagerActivity.java    From UltraViewPager with MIT License 5 votes vote down vote up
private void initUI() {
    indicatorStyle = (Spinner) findViewById(R.id.indicator);
    indicatorGravityHor = (Spinner) findViewById(R.id.indicator_gravity_hor);
    indicatorGravityVer = (Spinner) findViewById(R.id.indicator_gravity_ver);

    ArrayAdapter<CharSequence> indicatorAdapter = ArrayAdapter.createFromResource(this, R.array.indicator_style, android.R.layout.simple_spinner_item);
    indicatorAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    indicatorStyle.setAdapter(indicatorAdapter);

    ArrayAdapter<CharSequence> indicatorGraHorAdapter = ArrayAdapter.createFromResource(this, R.array.indicator_gravity_hor, android.R.layout.simple_spinner_item);
    indicatorGraHorAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    indicatorGravityHor.setAdapter(indicatorGraHorAdapter);

    ArrayAdapter<CharSequence> indicatorGraVerAdapter = ArrayAdapter.createFromResource(this, R.array.indicator_gravity_ver, android.R.layout.simple_spinner_item);
    indicatorGraVerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    indicatorGravityVer.setAdapter(indicatorGraVerAdapter);

    indicatorStyle.setOnItemSelectedListener(this);
    indicatorGravityHor.setOnItemSelectedListener(this);
    indicatorGravityVer.setOnItemSelectedListener(this);

    loopCheckBox = (CheckBox) findViewById(R.id.loop);
    loopCheckBox.setOnCheckedChangeListener(this);

    autoScrollCheckBox = (CheckBox) findViewById(R.id.autoscroll);
    autoScrollCheckBox.setOnCheckedChangeListener(this);

    indicatorBuildBtn = (Button) findViewById(R.id.indicator_build);
    indicatorBuildBtn.setOnClickListener(this);
}
 
Example 16
Source File: MainActivity.java    From AndroidDemoProjects with Apache License 2.0 5 votes vote down vote up
private void setupConnectionTypeSpinner() {
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
            this,
            R.array.connection_types,
            android.R.layout.simple_spinner_item );

    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    mTypeSpinner.setAdapter(adapter);
}
 
Example 17
Source File: FragmentPaymentChargeViewModel.java    From iGap-Android with GNU Affero General Public License v3.0 5 votes vote down vote up
private void onOpereatorChange(int arrayId) {
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(G.context, arrayId, R.layout.spinner_item_custom);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    fragmentPaymentChargeBinding.fpcSpinnerChargeType.setAdapter(adapter);
    fragmentPaymentChargeBinding.fpcSpinnerChargeType.setSelection(0);
    observeChargeTypeHint.set(View.GONE);
}
 
Example 18
Source File: MultiBlurActivity.java    From HokoBlur with Apache License 2.0 4 votes vote down vote up
private SpinnerAdapter makeSpinnerAdapter(@ArrayRes int arrayRes) {
    ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource(this,
            arrayRes, android.R.layout.simple_spinner_item);
    spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    return spinnerAdapter;
}
 
Example 19
Source File: MagpiMainActivity.java    From magpi-android with MIT License 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_magpi_main);
    
    try {
     GCMRegistrar.checkDevice(this);
     GCMRegistrar.checkManifest(this);
     final String idGcm = GCMRegistrar.getRegistrationId(this);
     if (TextUtils.isEmpty(idGcm)) {
     	Log.e("GCM", "NOT registered");
         GCMRegistrar.register(MagpiMainActivity.this, Config.SENDER_ID);
     } else {
     	Log.e("GCM", "Already registered" + idGcm);
     	if(isTimeToRegister())
     		new MagPiClient().registerDevice(this, idGcm);
     }
    } catch (UnsupportedOperationException ex) {
    	Log.e("GCM", "Google Cloud Messaging not supported - please install Google Apps package!");
    }

    mOnNavigationListener = new OnNavigationListener() {
        @Override
        public boolean onNavigationItemSelected(int position, long itemId) {
            return true;
        }
    };
    
    this.intialiseViewPager();
 
    CompatActionBarNavHandler handler = new CompatActionBarNavHandler(this);
    
    SpinnerAdapter mSpinnerAdapter = ArrayAdapter.createFromResource(this, R.array.dropdown_array,
            android.R.layout.simple_spinner_dropdown_item);
    
    getSupportActionBar().setListNavigationCallbacks(mSpinnerAdapter, mOnNavigationListener);
    getSupportActionBar().setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_TABS);
    
    final String CATEGORIES[] = getResources().getStringArray(R.array.dropdown_array);
    for (int i = 0; i < CATEGORIES.length; i++) {
        this.getSupportActionBar().addTab(this.getSupportActionBar().newTab().setText(
            CATEGORIES[i]).setTabListener(handler));
    }
    getSupportActionBar().setSelectedNavigationItem(0);
    
}
 
Example 20
Source File: DrawableTintingFragment.java    From graphics-samples with Apache License 2.0 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.tinting_fragment, container, false);

    // Set a drawable as the image to display
    mImage = v.findViewById(R.id.image);
    mImage.setImageResource(R.drawable.btn_default_normal_holo);

    // Get text labels and SeekBars for the four color components: ARGB
    mAlphaBar = v.findViewById(R.id.alphaSeek);
    mAlphaText = v.findViewById(R.id.alphaText);
    mGreenBar = v.findViewById(R.id.greenSeek);
    mGreenText = v.findViewById(R.id.greenText);
    mRedBar = v.findViewById(R.id.redSeek);
    mRedText = v.findViewById(R.id.redText);
    mBlueText = v.findViewById(R.id.blueText);
    mBlueBar = v.findViewById(R.id.blueSeek);

    // Set a listener to update tinted image when selections have changed
    mAlphaBar.setOnSeekBarChangeListener(mSeekBarListener);
    mRedBar.setOnSeekBarChangeListener(mSeekBarListener);
    mGreenBar.setOnSeekBarChangeListener(mSeekBarListener);
    mBlueBar.setOnSeekBarChangeListener(mSeekBarListener);

    // Set up the spinner for blend mode selection from a string array resource
    mBlendSpinner = v.findViewById(R.id.blendSpinner);
    SpinnerAdapter sa = ArrayAdapter.createFromResource(v.getContext(),
            R.array.blend_modes, android.R.layout.simple_spinner_dropdown_item);
    mBlendSpinner.setAdapter(sa);
    // Set a listener to update the tinted image when a blend mode is selected
    mBlendSpinner.setOnItemSelectedListener(mBlendListener);
    // Select the first item
    mBlendSpinner.setSelection(0);
    mMode = MODES[0];

    if (savedInstanceState != null) {
        // Restore the previous state if this fragment has been restored
        mBlendSpinner.setSelection(savedInstanceState.getInt(STATE_BLEND));
        mAlphaBar.setProgress(savedInstanceState.getInt(STATE_ALPHA));
        mRedBar.setProgress(savedInstanceState.getInt(STATE_RED));
        mGreenBar.setProgress(savedInstanceState.getInt(STATE_GREEN));
        mBlueBar.setProgress(savedInstanceState.getInt(STATE_BLUE));
    }

    // Apply the default blend mode and color
    updateTint(getColor(), getTintMode());

    return v;
}