当前位置: 首页>>代码示例>>Java>>正文


Java ArrayAdapter.createFromResource方法代码示例

本文整理汇总了Java中android.widget.ArrayAdapter.createFromResource方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayAdapter.createFromResource方法的具体用法?Java ArrayAdapter.createFromResource怎么用?Java ArrayAdapter.createFromResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.ArrayAdapter的用法示例。


在下文中一共展示了ArrayAdapter.createFromResource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.widget.ArrayAdapter; //导入方法依赖的package包/类
@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();
        }
    });

}
 
开发者ID:kunalrmhatre,项目名称:fussroll,代码行数:23,代码来源:RegisterActivity.java

示例2: onCreate

import android.widget.ArrayAdapter; //导入方法依赖的package包/类
@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();
        }
    });
}
 
开发者ID:braulio94,项目名称:Quadro,代码行数:27,代码来源:NewPostActivity.java

示例3: onCreate

import android.widget.ArrayAdapter; //导入方法依赖的package包/类
@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);
}
 
开发者ID:willowtreeapps,项目名称:spruce-android,代码行数:26,代码来源:SpruceActivity.java

示例4: onCreate

import android.widget.ArrayAdapter; //导入方法依赖的package包/类
@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);
    }
         
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:33,代码来源:Settings.java

示例5: onCreate

import android.widget.ArrayAdapter; //导入方法依赖的package包/类
@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);

}
 
开发者ID:Mikerr1111,项目名称:Library-System-Android,代码行数:81,代码来源:DropOff.java

示例6: initSpinners

import android.widget.ArrayAdapter; //导入方法依赖的package包/类
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);
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:9,代码来源:UnitConverterActivity.java

示例7: TimeSpanPicker

import android.widget.ArrayAdapter; //导入方法依赖的package包/类
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);
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:34,代码来源:TimeSpanPicker.java

示例8: onCreateView

import android.widget.ArrayAdapter; //导入方法依赖的package包/类
@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;
}
 
开发者ID:AbyxBelgium,项目名称:Loyalty,代码行数:30,代码来源:EditFragment.java

示例9: initSpinner

import android.widget.ArrayAdapter; //导入方法依赖的package包/类
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);
    }
 
开发者ID:LCA311,项目名称:leoapp-sources,代码行数:12,代码来源:NewSurveyDialog.java

示例10: onStart

import android.widget.ArrayAdapter; //导入方法依赖的package包/类
@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);
}
 
开发者ID:wax911,项目名称:anitrend-app,代码行数:15,代码来源:BottomSheetShare.java

示例11: onCreate

import android.widget.ArrayAdapter; //导入方法依赖的package包/类
@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);
}
 
开发者ID:AndroidNewbies,项目名称:Sanxing,代码行数:37,代码来源:CalendarActivity.java

示例12: initSpecificControls

import android.widget.ArrayAdapter; //导入方法依赖的package包/类
@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);
    }
}
 
开发者ID:mkeresztes,项目名称:AndiCar,代码行数:9,代码来源:UOMEditFragment.java

示例13: onCreate

import android.widget.ArrayAdapter; //导入方法依赖的package包/类
@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);
}
 
开发者ID:StylingAndroid,项目名称:PresenterLite,代码行数:8,代码来源:PresentationChooserActivity.java

示例14: loadPref

import android.widget.ArrayAdapter; //导入方法依赖的package包/类
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);
}
 
开发者ID:dftec-es,项目名称:planetcon,代码行数:9,代码来源:StartActivity.java

示例15: initSpinner

import android.widget.ArrayAdapter; //导入方法依赖的package包/类
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;
    }
 
开发者ID:CamelCase11,项目名称:Search-em-All,代码行数:13,代码来源:MainFragment.java


注:本文中的android.widget.ArrayAdapter.createFromResource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。