List of usage examples for android.widget ArrayAdapter createFromResource
public static @NonNull ArrayAdapter<CharSequence> createFromResource(@NonNull Context context, @ArrayRes int textArrayResId, @LayoutRes int textViewResId)
From source file:com.gh4a.activities.ExploreActivity.java
@Override public void onCreate(Bundle savedInstanceState) { setTheme(Gh4Application.THEME);/* ww w . j a v a2 s . co m*/ super.onCreate(savedInstanceState); if (!isOnline()) { setErrorView(); return; } setContentView(R.layout.explore); mActionBar = getSupportActionBar(); mActionBar.setDisplayShowTitleEnabled(false); mActionBar.setDisplayHomeAsUpEnabled(true); ArrayAdapter<CharSequence> list = ArrayAdapter.createFromResource(mActionBar.getThemedContext(), R.array.explore_item, R.layout.sherlock_spinner_item); list.setDropDownViewResource(R.layout.row_simple); mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); mActionBar.setListNavigationCallbacks(list, this); setPageIndicator(mActionBar.getSelectedNavigationIndex()); }
From source file:com.google.android.gms.example.apidemo.DFPCustomTargetingFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mSportsSpinner = (Spinner) getView().findViewById(R.id.customtargeting_spn_sport); mLoadButton = (Button) getView().findViewById(R.id.customtargeting_btn_loadad); mAdView = (PublisherAdView) 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); mSportsSpinner.setAdapter(adapter);// w w w . ja v a 2s . com mLoadButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PublisherAdRequest adRequest = new PublisherAdRequest.Builder().addCustomTargeting( getString(R.string.customtargeting_key), (String) mSportsSpinner.getSelectedItem()).build(); mAdView.loadAd(adRequest); } }); }
From source file:de.quist.app.maps.example.LayersDemoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layers_demo); Spinner spinner = (Spinner) findViewById(R.id.layers_spinner); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.layers_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter);//from ww w . j a v a 2 s.c o m spinner.setOnItemSelectedListener(this); mTrafficCheckbox = (CheckBox) findViewById(R.id.traffic); mMyLocationCheckbox = (CheckBox) findViewById(R.id.my_location); mBuildingsCheckbox = (CheckBox) findViewById(R.id.buildings); mIndoorCheckbox = (CheckBox) findViewById(R.id.indoor); SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); mapFragment.getMapAsync(this); }
From source file:nl.jalava.appostle.SortDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.sort_dialog, container, false); getDialog().setTitle(getString(R.string.sort_title)); // Alphabetically or by name. final Spinner spinner_types = (Spinner) v.findViewById(R.id.sort_type_spinner); ArrayAdapter<CharSequence> adapter_types = ArrayAdapter.createFromResource(getActivity(), R.array.sort_types, android.R.layout.simple_spinner_item); adapter_types.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner_types.setAdapter(adapter_types); spinner_types.setSelection(mSort);//from ww w .jav a 2 s . c o m // Ascending or descending. final Spinner spinner_directions = (Spinner) v.findViewById(R.id.sort_direction_spinner); ArrayAdapter<CharSequence> adapter_directions = ArrayAdapter.createFromResource(getActivity(), R.array.sort_directions, android.R.layout.simple_spinner_item); adapter_directions.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner_directions.setAdapter(adapter_directions); spinner_directions.setSelection(mDir); Button OK_Button = (Button) v.findViewById(R.id.ok_button); OK_Button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mSort = spinner_types.getSelectedItemPosition(); mDir = spinner_directions.getSelectedItemPosition(); SortDialogListener activity = (SortDialogListener) getActivity(); activity.onFinishSortDialog(mSort, mDir); dismiss(); } }); Button Cancel_Button = (Button) v.findViewById(R.id.cancelButton); Cancel_Button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismiss(); } }); return v; }
From source file:com.explovia.mapdemo.LayersDemoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layers_demo); Spinner spinner = (Spinner) findViewById(R.id.layers_spinner); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.layers_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter);/*w w w. j a v a 2 s .co m*/ spinner.setOnItemSelectedListener(this); mTrafficCheckbox = (CheckBox) findViewById(R.id.traffic); mMyLocationCheckbox = (CheckBox) findViewById(R.id.my_location); mBuildingsCheckbox = (CheckBox) findViewById(R.id.buildings); mIndoorCheckbox = (CheckBox) findViewById(R.id.indoor); setUpMapIfNeeded(); }
From source file:nl.jalava.appostle.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mContext = getBaseContext();//from w ww .ja v a 2 s . c o m Toolbar mToolbar = (Toolbar) findViewById(R.id.app_bar); setSupportActionBar(mToolbar); // Spinner for choosing application type. Spinner spinner_app = (Spinner) findViewById(R.id.app_types); spinner_app.setVisibility(View.VISIBLE); ArrayAdapter<CharSequence> apptype = ArrayAdapter.createFromResource(mToolbar.getContext(), R.array.app_types, android.R.layout.simple_spinner_item); apptype.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner_app.setAdapter(apptype); // Select. int app_type = getSharedPreferences("AppListFragment", Context.MODE_PRIVATE) .getInt(AppListFragment.PREFS_APP_TYPE, 0); spinner_app.setSelection(app_type); spinner_app.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapter, View v, int position, long id) { AppListFragment fragment = (AppListFragment) getFragmentManager() .findFragmentById(R.id.listFragment); if (fragment != null && fragment.isVisible()) { fragment.doUpdate(position); } } @Override public void onNothingSelected(AdapterView<?> arg0) { // Not used. } }); /* mDrawer = (NavigationView) findViewById(R.id.main_drawer); mDrawer.setNavigationItemSelectedListener(this); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.drawer_open, R.string.drawer_close); mDrawerLayout.setDrawerListener(mDrawerToggle); mDrawerToggle.syncState(); mDrawerLayout.closeDrawer(GravityCompat.START); */ }
From source file:com.narkii.security.info.SecureDataFragment.java
@SuppressWarnings("deprecation") @Override//from ww w .ja v a 2s . c om public void onActivityCreated(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onActivityCreated(savedInstanceState); initViews(); certiAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.spinner_certificate_situ, android.R.layout.simple_spinner_item); certiAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); certificateSpinner.setAdapter(certiAdapter); safeTypeAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_spinner_item, null, new String[] { SafetyPermitType.COLUMN_NAME }, new int[] { android.R.id.text1 }); safeTypeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); safeTypeSpinner.setAdapter(safeTypeAdapter); f2TypeAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_spinner_item, null, new String[] { VarityType.COLUMN_NAME }, new int[] { android.R.id.text1 }); f2TypeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); f2TypeSpinner.setAdapter(f2TypeAdapter); getLoaderManager().initLoader(Constants.SPINNER_SAFETY_PERMIT_TYPE_ID, null, this); getLoaderManager().restartLoader(Constants.SPINNER_VARITY_TYPE_ID, null, this); long id = getArguments().getLong("enterpriseId", 0); if (id == 0) { } else { Bundle bundle = new Bundle(); bundle.putLong("id", id); getLoaderManager().restartLoader(Constants.ENTERPRISE_INFO_ID, bundle, this); getLoaderManager().restartLoader(Constants.FILING_ID, bundle, this); } }
From source file:com.microsoft.office365.meetingfeedback.CalendarActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mCalendarViewPager = (ViewPager) findViewById(R.id.activity_calendar_viewpager); mSpinner = (Spinner) findViewById(R.id.activity_calendar_select_role); mSpinnerAdapter = ArrayAdapter.createFromResource(this, R.array.meeting_filter_spinner_options, android.R.layout.simple_spinner_item); mSpinner.setAdapter(mSpinnerAdapter); mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override/*from w w w . java 2 s. c om*/ public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { updateCurrentFilter(); } @Override public void onNothingSelected(AdapterView<?> parent) { updateCurrentFilter(); } }); updateCurrentFilter(); mCalendarViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { mPage = position; onPageSet(mPage); mCalendarRangeFragment.setActivePage(mPage); } @Override public void onPageScrollStateChanged(int state) { } }); if (savedInstanceState == null) { requestCalendarData(); mCalendarRangeFragment = new CalendarRangeFragment(); getSupportFragmentManager().beginTransaction() .add(R.id.activity_calendar_fragment_frame, mCalendarRangeFragment).commit(); } else { mCalendarRangeFragment = (CalendarRangeFragment) getSupportFragmentManager() .findFragmentById(R.id.activity_calendar_fragment_frame); setupViewPagerState(); } //schedule the rating service to begin polling for new meetings mRatingServiceManager.loadMyMeetingsAndSchedulePolling(mRatingServiceAlarmManager); }
From source file:com.actionbarsherlock.sample.styled.MainActivity.java
/** Called when the activity is first created. */ @Override/*from w w w . j av a 2 s .c om*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final ActionBar ab = getSupportActionBar(); // set defaults for logo & home up ab.setDisplayHomeAsUpEnabled(showHomeUp); ab.setDisplayUseLogoEnabled(useLogo); // set up tabs nav for (int i = 1; i < 4; i++) { ab.addTab(ab.newTab().setText("Tab " + i).setTabListener(this)); } // set up list nav ab.setListNavigationCallbacks( ArrayAdapter.createFromResource(this, R.array.sections, R.layout.sherlock_spinner_dropdown_item), new OnNavigationListener() { public boolean onNavigationItemSelected(int itemPosition, long itemId) { // FIXME add proper implementation rotateLeftFrag(); return false; } }); // default to tab navigation showTabsNav(); // create a couple of simple fragments as placeholders final int MARGIN = 16; leftFrag = new RoundedColourFragment(getResources().getColor(R.color.android_green), 1f, MARGIN, MARGIN / 2, MARGIN, MARGIN); rightFrag = new RoundedColourFragment(getResources().getColor(R.color.honeycombish_blue), 2f, MARGIN / 2, MARGIN, MARGIN, MARGIN); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.add(R.id.root, leftFrag); ft.add(R.id.root, rightFrag); ft.commit(); }
From source file:me.willeponken.opendoor.FirstRunSlide.java
@Nullable @Override/*from w w w. j a v a 2s . c o m*/ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View v = inflater.inflate(layoutResId, container, false); if (R.layout.fragment_initial1 == layoutResId) { editText = (EditText) v.findViewById(R.id.defaultNumber); Spinner spinner = (Spinner) v.findViewById(R.id.lab_spinner); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.lab_spinner_titles, R.layout.custom_spinner_item); adapter.setDropDownViewResource(android.R.layout.select_dialog_item); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(this); } return v; }