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:br.com.frs.foodrestrictions.FoodMessages.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.activity_restriction_message, container, false); restrictList = foodIconList.getFoodRestrictionList(true); llAllergic = (LinearLayout) v.findViewById(R.id.llAllergic); llDontEat = (LinearLayout) v.findViewById(R.id.llDontEat); allergicText = (TextView) v.findViewById(R.id.messages_allergic_text); dontEatText = (TextView) v.findViewById(R.id.messages_dont_eat_text); Spinner spinner = (Spinner) v.findViewById(R.id.spinner_language); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(v.getContext(), R.array.languages_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter);//from w w w.ja v a 2 s . c om spinner.setOnItemSelectedListener(this); return v; }
From source file:net.basilwang.ViewPagerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { //setTheme(SampleList.THEME); //Used for theme switching in samples super.onCreate(savedInstanceState); /*// w w w . ja v a2 s . c o m * Most interactions with what would otherwise be the system UI should * now be done through this instance. Content, title, action bar, and * menu inflation can all be done. * * All of the base activities use this class to provide the normal * action bar functionality so everything that they can do is possible * using this static attacFragmentStatePagerSupporthment method. * * Calling something like setContentView or getActionBar on this * instance is required in order to properly set up the wrapped layout * and dispatch menu events (if they are needed). */ //getSherlock().setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW); //((TextView)findViewById(R.id.text)).setText(R.string.static_attach_content); viewtypes = getResources().getStringArray(R.array.viewtype); Context context = getSupportActionBar().getThemedContext(); ArrayAdapter<CharSequence> viewTypeList = ArrayAdapter.createFromResource(context, R.array.viewtype, R.layout.sherlock_spinner_item); viewTypeList.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item); //getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); //getSupportActionBar().setListNavigationCallbacks(viewTypeList, this); getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); for (String viewtype : viewtypes) { ActionBar.Tab tab = getSupportActionBar().newTab(); tab.setText(viewtype); tab.setTabListener(this); getSupportActionBar().addTab(tab); } }
From source file:com.actionbarsherlock.sample.styledactionbar.MainActivity.java
/** Called when the activity is first created. */ @Override/*from ww w . j a va2 s. c o m*/ 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, android.R.layout.simple_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:org.tomasdavid.vehicleroutingproblem.fragments.MainFragment.java
/** * {@inheritDoc}/*from w ww.j ava 2 s . c o m*/ */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_main, container, false); // time limit number picker initialization NumberPicker numberPicker = (NumberPicker) view.findViewById(R.id.timeLimitPicker); numberPicker.setMinValue(MIN_TIME_LIMIT); numberPicker.setMaxValue(MAX_TIME_LIMIT); numberPicker.setValue(DEFAULT_TIME_LIMIT); numberPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS); // welcome text TextView welcomeText = (TextView) view.findViewById(R.id.welcome_text); welcomeText.setText(Html.fromHtml(getString(R.string.welcome_text))); // spinner for choosing algorithm initialization Spinner algSpinner = (Spinner) view.findViewById(R.id.algorithm_spinner); ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.algorithms, android.R.layout.simple_spinner_item); spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); algSpinner.setAdapter(spinnerAdapter); setHasOptionsMenu(true); return view; }
From source file:com.gh4a.ExploreActivity.java
@Override public void onCreate(Bundle savedInstanceState) { setTheme(Gh4Application.THEME);// ww w . j a v a 2 s . co m super.onCreate(savedInstanceState); mExploreItem = getIntent().getExtras().getInt("exploreItem"); if (!isOnline()) { setErrorView(); return; } setContentView(R.layout.explore); mActionBar = getSupportActionBar(); mActionBar.setDisplayShowTitleEnabled(false); mActionBar.setDisplayHomeAsUpEnabled(true); Context context = getSupportActionBar().getThemedContext(); ArrayAdapter<CharSequence> list = ArrayAdapter.createFromResource(context, R.array.explore_item, R.layout.sherlock_spinner_item); list.setDropDownViewResource(R.layout.row_simple); mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); getSupportActionBar().setListNavigationCallbacks(list, this); getSupportActionBar().setSelectedNavigationItem(mExploreItem); setPageIndicator(); }
From source file:com.fachri.makers.pets.EditorActivity.java
/** * Setup the dropdown spinner that allows the user to select the gender of the pet. *//*from w w w . j a v a2 s. c o m*/ private void setupSpinner() { // Create adapter for spinner. The list options are from the String array it will use // the spinner will use the default layout ArrayAdapter genderSpinnerAdapter = ArrayAdapter.createFromResource(this, R.array.array_gender_options, android.R.layout.simple_spinner_item); // Specify dropdown layout style - simple list view with 1 item per line genderSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line); // Apply the adapter to the spinner mGenderSpinner.setAdapter(genderSpinnerAdapter); // Set the integer mSelected to the constant values mGenderSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { String selection = (String) parent.getItemAtPosition(position); if (!TextUtils.isEmpty(selection)) { if (selection.equals(getString(R.string.gender_male))) { mGender = 1; // Male } else if (selection.equals(getString(R.string.gender_female))) { mGender = 2; // Female } else { mGender = 0; // Unknown } } } // Because AdapterView is an abstract class, onNothingSelected must be defined @Override public void onNothingSelected(AdapterView<?> parent) { mGender = 0; // Unknown } }); }
From source file:com.example.d062654.faciliman._3_IncidentDescription.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ll = (RelativeLayout) inflater.inflate(R.layout.incidentdescription, container, false); sendbutton = ((Button) ll.findViewById(R.id.descr_finished_button)); sendbutton.setOnClickListener(this); locdescrp = ((TextView) ll.findViewById(R.id.detailed_location_description)); locdescrp.setOnClickListener(this); damagdescrinfo = ((TextView) ll.findViewById(R.id.damage_description_information)); damagdescrinfo.setOnClickListener(this); spinner = ((Spinner) ll.findViewById(R.id.facilities_spinner)); title = (EditText) ll.findViewById(R.id.title); // Create an ArrayAdapter using the string array and a default spinner layout ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(ll.getContext(), R.array.facilities, 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);/*w ww. j a va2 s.c om*/ // Inflate the layout for this fragment return ll; }
From source file:com.dawkinstan.simplebalance.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); this.actionbar = getSupportActionBar(); this.actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); this.actionbar.addTab(this.actionbar.newTab().setText("Balance").setTabListener(this)); this.actionbar.addTab(this.actionbar.newTab().setText("Transactions").setTabListener(this)); this.type = -1; // Setting display where money is shown as unclickable EditText cmDisplay;// w ww. j a v a2 s . c o m cmDisplay = (EditText) findViewById(R.id.currentAmount); cmDisplay.setClickable(false); cmDisplay.setFocusable(false); Spinner spinner = (Spinner) findViewById(R.id.type_spinner); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.type_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); new Spr(); // Getting preferences SharedPreferences settings = getSharedPreferences(PREFS_NAME, MODE_PRIVATE); boolean firstLoad = settings.getBoolean("firstLoad", true); ds = new DataSource(this); if (firstLoad) { // First load intent Intent intent = new Intent(this, MTSettings.class); try { startActivityForResult(intent, 1); SharedPreferences.Editor edit = settings.edit(); edit.putBoolean("firstLoad", false); edit.commit(); } // Catches exception of the activity not existing catch (Exception e) { } } else { // Formats string to have money symbol in front. double currentMoney; try { currentMoney = Double.parseDouble(settings.getString("ammount", "0.00").replace("$|,", "")); } catch (Exception e) { currentMoney = 0; } this.setNewAmountInView(currentMoney); this.beforePurchase = currentMoney; } // Sets button as unclickable Button updateButton = (Button) findViewById(R.id.button_update); updateButton.setEnabled(false); // Listener to update the view of the ammount of money changed updateButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onUpdate(view); } }); }
From source file:net.meiolania.apps.habrahabr.activities.HubsActivity.java
private void showActionBar() { ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); ArrayAdapter<CharSequence> list = ArrayAdapter.createFromResource(getSupportActionBar().getThemedContext(), R.array.hubs_list, R.layout.sherlock_spinner_item); list.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item); actionBar.setListNavigationCallbacks(list, this); }
From source file:can.yrt.onebusaway.ReportStopProblemFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { // Set the stop name. Bundle args = getArguments();//from w w w . ja va2 s . c om final TextView stopName = (TextView) view.findViewById(R.id.stop_name); stopName.setText(MyTextUtils.toTitleCase(args.getString(STOP_NAME))); // // The code spinner // mCodeView = (Spinner) view.findViewById(R.id.report_problem_code); ArrayAdapter<?> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.report_stop_problem_code, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mCodeView.setAdapter(adapter); // Comment mUserComment = (TextView) view.findViewById(R.id.report_problem_comment); if (savedInstanceState != null) { int position = savedInstanceState.getInt(CODE); mCodeView.setSelection(position); CharSequence comment = savedInstanceState.getCharSequence(USER_COMMENT); mUserComment.setText(comment); } }