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

The following are Jave code examples for showing how to use createFromResource() of the android.widget.ArrayAdapter class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: fussroll   File: RegisterActivity.java   Source Code and License Vote up 7 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_register);

    editText = (EditText) findViewById(R.id.editText);
    spinner = (Spinner) findViewById(R.id.spinner);
    textInputLayout = (TextInputLayout) findViewById(R.id.textInputLayout);

    ArrayAdapter<CharSequence> arrayAdapter = ArrayAdapter.createFromResource(this, R.array.countries, R.layout.spinner_layout);
    arrayAdapter.setDropDownViewResource(R.layout.spinner_layout);
    spinner.setAdapter(arrayAdapter);

    AppCompatButton appCompatButton = (AppCompatButton) findViewById(R.id.button);
    appCompatButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            register();
        }
    });

}
 
Example 2
Project: Quadro   File: NewPostActivity.java   Source Code and License Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_new_post);

    mDatabase = FirebaseDatabase.getInstance().getReference();
    mStorage = FirebaseStorage.getInstance().getReference();

    mCriminalPicture = (ImageView)findViewById(R.id.picture_of_criminal);
    mCriminalPicture.setOnClickListener(this);
    mCriminalNameField = (EditText)findViewById(R.id.field_criminal_name);
    mBodyField = (EditText) findViewById(R.id.field_body);
    mSubmitButton = (FloatingActionButton) findViewById(R.id.fab_submit_post);
    mSpinnerType = (Spinner)findViewById(R.id.crime_type_spinner);
    ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource(NewPostActivity.this,
            R.array.crimeType, android.R.layout.simple_spinner_item);
    spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mSpinnerType.setOnItemSelectedListener(NewPostActivity.this);
    mSpinnerType.setAdapter(spinnerAdapter);
    mSubmitButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            submitPost();
        }
    });
}
 
Example 3
Project: spruce-android   File: SpruceActivity.java   Source Code and License Vote up 6 votes
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.fragment_pager);

    FragmentManager fm = getSupportFragmentManager();

    VerticalViewPager verticalPager = (VerticalViewPager) findViewById(R.id.vertical_pager);
    VerticalPagerAdapter adapter = new VerticalPagerAdapter(fm);
    verticalPager.setAdapter(adapter);

    Toolbar toolBar = (Toolbar) findViewById(R.id.tool_bar);
    setSupportActionBar(toolBar);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayShowTitleEnabled(false);
    }

    sortDropDown = (Spinner) findViewById(R.id.sort_selection);
    ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource(this,
            R.array.sort_functions,
            R.layout.spinner_item);
    spinnerAdapter.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item);
    sortDropDown.setAdapter(spinnerAdapter);
}
 
Example 4
Project: buildAPKsApps   File: Settings.java   Source Code and License Vote up 6 votes
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.settings);
    
    Button endgame = (Button) findViewById(R.id.endgame);
    endgame.setOnClickListener(ClickListener);
          
    Spinner spinner = (Spinner) findViewById(R.id.sphofentries);
    ArrayAdapter adapter = ArrayAdapter.createFromResource( this, R.array.hofentries_array , android.R.layout.simple_spinner_dropdown_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(ItemSelectedListener);
    
    RadioButton rbclassic = (RadioButton) findViewById(R.id.rbclassic);
    RadioButton rbletters = (RadioButton) findViewById(R.id.rbletters);
    rbclassic.setOnClickListener(RadioListener);
    rbletters.setOnClickListener(RadioListener);
    
    prefs = new Preferences(this);             // Instantiating Preferences in prefs global variable

    spinner.setSelection(prefs.scoresnumpos);

    if (prefs.notationstyle == "classic") {
		rbclassic.setChecked(true);
		rbletters.setChecked(false);
    }
    else if (prefs.notationstyle == "letters") {
		rbclassic.setChecked(false);
		rbletters.setChecked(true);
    }
         
}
 
Example 5
Project: Library-System-Android   File: DropOff.java   Source Code and License Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.dropoff);

    View chooseButton = findViewById(R.id.choosedatedrop_button);
    chooseButton.setOnClickListener(this);

    //Array For Day Spinner
    ampm[0] = "AM";
    ampm[1] = "PM";
    Spinner daySpinner = (Spinner) findViewById(R.id.day_spinner);
    Spinner spinner = (Spinner) findViewById(R.id.month_spinner);
    for (int i = 0; i < thirtyOneDays.length; i++) {
        thirtyOneDays[i] = Integer.toString(1 + i);
    }
    for (int i = 0; i < twentyEightDays.length; i++) {
        twentyEightDays[i] = Integer.toString(1 + i);
    }
    for (int i = 0; i < twentyNineDays.length; i++) {
        twentyNineDays[i] = Integer.toString(1 + i);
    }
    for (int i = 0; i < thirtyDays.length; i++) {
        thirtyDays[i] = Integer.toString(1 + i);
    }
    for (int i = 0; i < hours.length; i++) {
        hours[i] = Integer.toString(1 + i) + ":00";
    }

    //Month Spinner
    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
            R.array.month, android.R.layout.simple_spinner_item);
    // Specify the layout to use when the list of choices appears
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
    spinner.setAdapter(adapter);
    String selected = spinner.getSelectedItem().toString();

    System.out.println("selected: " + selected);
    spinner.setOnItemSelectedListener(this);

    //Day Spinner
    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<String> dayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, thirtyOneDays);
    // Specify the layout to use when the list of choices appears
    dayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
    daySpinner.setAdapter(dayAdapter);

    //Year Spinner
    Spinner yearSpinner = (Spinner) findViewById(R.id.year_spinner);
    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<CharSequence> yearAdapter = ArrayAdapter.createFromResource(this,
            R.array.years, android.R.layout.simple_spinner_item);
    // Specify the layout to use when the list of choices appears
    yearAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
    yearSpinner.setAdapter(yearAdapter);
    yearSpinner.setOnItemSelectedListener(this);

    //Hour Spinner
    Spinner hourSpinner = (Spinner) findViewById(R.id.hour_spinner);
    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<String> hourAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, hours);
    // Specify the layout to use when the list of choices appears
    hourAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
    hourSpinner.setAdapter(hourAdapter);

    //ampm Spinner
    Spinner ampmSpinner = (Spinner) findViewById(R.id.ampm_spinner);
    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<String> ampmAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, ampm);
    // Specify the layout to use when the list of choices appears
    ampmAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
    ampmSpinner.setAdapter(ampmAdapter);

}
 
Example 6
Project: buildAPKsSamples   File: UnitConverterActivity.java   Source Code and License Vote up 5 votes
private void initSpinners(int category) {
	ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
			this, this.getCategoryArrayResId(category),
			android.R.layout.simple_spinner_item);
	adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
	this.inputUnit.setAdapter(adapter);
	this.outputUnit.setAdapter(adapter);
}
 
Example 7
Project: ultrasonic   File: TimeSpanPicker.java   Source Code and License Vote up 5 votes
public TimeSpanPicker(Context context, AttributeSet attrs, int defStyle)
{
	super(context, attrs, defStyle);

	this.context = context;

	final LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	dialog = inflater.inflate(R.layout.time_span_dialog, this, true);

	timeSpan = new TimeSpan(-1);

	timeSpanEditText = (EditText) dialog.findViewById(R.id.timeSpanEditText);
	timeSpanEditText.setText("0");

	timeSpanSpinner = (Spinner) dialog.findViewById(R.id.timeSpanSpinner);
	timeSpanDisableCheckbox = (CheckBox) dialog.findViewById(R.id.timeSpanDisableCheckBox);

	timeSpanDisableCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
	{
		@Override
		public void onCheckedChanged(CompoundButton compoundButton, boolean b)
		{
			timeSpanEditText.setEnabled(!b);
			timeSpanSpinner.setEnabled(!b);
		}
	});

	adapter = ArrayAdapter.createFromResource(context, R.array.shareExpirationNames, android.R.layout.simple_spinner_item);
	adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
	timeSpanSpinner.setAdapter(adapter);

	timeSpanSpinner.setOnItemSelectedListener(this);
}
 
Example 8
Project: Loyalty   File: EditFragment.java   Source Code and License Vote up 5 votes
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    Bundle args = getArguments();

    db = new Database(getActivity());
    db.openDatabase();
    data = db.getCardByID(args.getLong(Constants.INTENT_CARD_ID_ARG));
    db.closeDatabase();

    View view = inflater.inflate(R.layout.fragment_edit, container, false);

    storeName = view.findViewById(R.id.storeName);
    storeName.setText(data.getName());

    logoURL = view.findViewById(R.id.logoURL);
    logoURL.setText(data.getImageURL());

    barcode = view.findViewById(R.id.barcode);
    barcode.setText(data.getBarcode());

    formatSpinner = view.findViewById(R.id.formatSpinner);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.format_array, android.R.layout.simple_spinner_item);
    formatSpinner.setOnItemSelectedListener(this);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    formatSpinner.setAdapter(adapter);
    formatSpinner.setSelection(adapter.getPosition(data.getFormat().toString()));

    return view;
}
 
Example 9
Project: leoapp-sources   File: NewSurveyDialog.java   Source Code and License Vote up 5 votes
private void initSpinner() {

        if (stage != layouts.length - 1)
            return;

        Spinner s = findViewById(R.id.spinner2);
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(Utils.getContext(),
                R.array.level, R.layout.spinner_item);
        adapter.setDropDownViewResource(R.layout.spinner_item);
        s.setAdapter(adapter);
    }
 
Example 10
Project: anitrend-app   File: BottomSheetShare.java   Source Code and License Vote up 5 votes
@Override
public void onStart() {
    super.onStart();
    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getContext(), R.array.post_share_types, R.layout.adapter_spinner_item);
    // Specify the layout to use when the list of choices appears
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
    mContentType.setAdapter(adapter);

    mContentType.setOnItemSelectedListener(this);
    if(bottomSheetBehavior.getState() != BottomSheetBehavior.STATE_EXPANDED)
        bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
 
Example 11
Project: Sanxing   File: CalendarActivity.java   Source Code and License Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Object receivedObject = getIntent().getSerializableExtra("tab");
    if(receivedObject != null) tabPosition = (int)receivedObject;
    setContentView(R.layout.activity_calendar);
    ButterKnife.bind(this);

    //////// Toolbar ////////
    // Set the toolbar as the default action bar of the window
    setSupportActionBar(toolbar);
    // Disable the title
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    // Enable the back button
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });

    //////// Spinner ////////
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
            R.array.calendar_spinner_array,
            R.layout.calendar_spinner);
    adapter.setDropDownViewResource(R.layout.spinner_items);
    spinner.setAdapter(adapter);
    spinner.setSelection(tabPosition);


    habitCalendarFrag.setVisibility(View.GONE);
    taskCalendarFrag.setVisibility(View.GONE);
    timeLeftCalendarFrag.setVisibility(View.GONE);
}
 
Example 12
Project: AndiCar   File: UOMEditFragment.java   Source Code and License Vote up 5 votes
@Override
protected void initSpecificControls() {
    if (getActivity() != null) {
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.uom_type_entries, android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spnUomType.setAdapter(adapter);
    }
}
 
Example 13
Project: PresenterLite   File: PresentationChooserActivity.java   Source Code and License Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.chooser);
    adapter = ArrayAdapter.createFromResource(this, R.array.presentations, android.R.layout.simple_list_item_1);
    setListAdapter(adapter);
}
 
Example 14
Project: planetcon   File: StartActivity.java   Source Code and License Vote up 5 votes
private void loadPref(SharedPreferences prefs, Spinner spinner, int id, String key, String def) {
    // temporary adapter created to get the position of an item inside the array of values
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, id, android.R.layout.simple_spinner_item);
    String selectedString = prefs.getString(key, def);
    int position = adapter.getPosition(selectedString);
    // Force the spinner to load the stored preference
    spinner.setSelection(position);
}
 
Example 15
Project: Search-em-All   File: MainFragment.java   Source Code and License Vote up 5 votes
private boolean initSpinner() {

        ArrayAdapter<CharSequence> mSpinnerAdapter = ArrayAdapter.createFromResource(
                getActivity(),
                R.array.spinner_items,
                android.R.layout.simple_spinner_item);

        mSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_list_item_1);
        mSearchScopeSpinner.setAdapter(mSpinnerAdapter);
        mSearchScopeSpinner.setOnItemSelectedListener(this);
        return true;
    }
 
Example 16
Project: DOUSalaries   File: SalaryWidgetFragment.java   Source Code and License Vote up 5 votes
@Override
protected void initUI() {
    ArrayAdapter<CharSequence> cityAdapter = ArrayAdapter.createFromResource(getActivity(),
            R.array.array_cities, android.R.layout.simple_spinner_item);
    cityAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    citySpinner.setAdapter(cityAdapter);
    citySpinner.setSelection(1);//set Kiev default city
    citySpinner.setOnItemSelectedListener(onItemSelectedListener);
    ArrayAdapter<CharSequence> langAdapter = ArrayAdapter.createFromResource(getActivity(),
            R.array.prog_lang, android.R.layout.simple_spinner_item);
    langAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    langSpinner.setAdapter(langAdapter);
    langSpinner.setSelection(1);//set Java default language
    langSpinner.setOnItemSelectedListener(onItemSelectedListener);
    ArrayAdapter<CharSequence> posAdapter = ArrayAdapter.createFromResource(getActivity(),
            R.array.array_job_title, android.R.layout.simple_spinner_item);
    posAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    posSpinner.setAdapter(posAdapter);//set Software engineer default job title
    posSpinner.setOnItemSelectedListener(onItemSelectedListener);
    seekExp.setOnSeekBarChangeListener(onSeekBarChangeListener);
    updateExperience();
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            updateData();
        }
    });
    salaryDetails.setText(AppUtils.fromHtml(getString(R.string.link_more_details)));
    salarySurveys.setText(AppUtils.fromHtml(getString(R.string.link_salary_surveys)));
    salaryDescription.setText(AppUtils.fromHtml(getString(R.string.link_max_email)));
    swipeRefreshLayout.setColorSchemeResources(R.color.colorWhite);
    swipeRefreshLayout.setProgressBackgroundColorSchemeColor(
            ContextCompat.getColor(getActivity(), R.color.colorPrimary));

    updateData();//load data
}
 
Example 17
Project: TextEmoji   File: EmojiFragment.java   Source Code and License Vote up 5 votes
private void initOptions(View root) {
    mWithShadow = SharePreferencesUtils.withShadow(getActivity(), false);
    mTextSize = SharePreferencesUtils.textSize(getActivity(), mDefaultTextSize);

    SeekBar seekBar = (SeekBar) root.findViewById(R.id.text_size);
    seekBar.setProgress((mTextSize - mMinTextSize) / mSpanPerSegment);

    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getContext(), R.array.gif_source_array, android.R.layout.simple_spinner_dropdown_item);
    mGifSourceSpinner.setAdapter(adapter);

    int source = SharePreferencesUtils.getInt(getContext(), KEY_GIF_SORUCE);
    mGifSourceSpinner.setSelection(source);
}
 
Example 18
Project: SecScanQR   File: TextGeneratorActivity.java   Source Code and License Vote up 4 votes
/**
 * Standard Android on create method that gets called when the activity
 * initialized.
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_text_generator);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    text = (EditText) findViewById(R.id.txtQR);
    image = (ImageView) findViewById(R.id.image);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    //Setup the Spinner Menu for the different formats
    Spinner spinner = (Spinner) findViewById(R.id.spinner);
    spinner.setOnItemSelectedListener(this);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
            R.array.text_formats_array, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);


    //If the device were rotated then restore information
    if(savedInstanceState != null){
        text2Qr = (String) savedInstanceState.get(STATE_TEXT);
        text.setText(text2Qr);
    }

    // Get intent, action and MINE type and check if the intent was started by a share to modul from an other app
    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();

    if (Intent.ACTION_SEND.equals(action) && type != null){
        if("text/plain".equals(type)){
            handleSendText(intent); //call method to handle sended text
        }
    }

    //OnClickListener for the "+" Button and functionality
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            text2Qr = text.getText().toString().trim();
            if(text2Qr.equals("")){
                Toast.makeText(getApplicationContext(), getResources().getText(R.string.error_text_first), Toast.LENGTH_SHORT).show();
            } else {
                multiFormatWriter = new MultiFormatWriter();
                try{
                    BitMatrix bitMatrix = multiFormatWriter.encode(text2Qr, format, 500,500);
                    BarcodeEncoder barcodeEncoder = new BarcodeEncoder();
                    bitmap = barcodeEncoder.createBitmap(bitMatrix);
                    image.setImageBitmap(bitmap);
                } catch (Exception e){
                    Toast.makeText(activity.getApplicationContext(), getResources().getText(R.string.error_generate), Toast.LENGTH_LONG).show();
                }
            }

        }
    });

}
 
Example 19
Project: SystemUITuner2   File: Demo.java   Source Code and License Vote up 4 votes
private void setSpinnerAdapters(Spinner spinner, int arrayID) {
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(activity.getApplicationContext(),
            arrayID, activity.setThings.Dark ? R.layout.spinner_items_dark : R.layout.spinner_items_light); //set correct spinner text color
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
}
 
Example 20
Project: planetcon   File: ListPlayersAdapter.java   Source Code and License Vote up 4 votes
private void loadPrefValue(CatchingSpinner spinner, int id, String item) {
    //Get the position of an item inside the array of values (resource id), and set as selected in the spinner
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(mContext, id, android.R.layout.simple_spinner_item);
    int position = adapter.getPosition(item);
    spinner.setSelection(position);
}