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:de.esailors.android.widget.scratch.example.ExampleActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); getSupportActionBar().setListNavigationCallbacks( ArrayAdapter.createFromResource(getSupportActionBar().getThemedContext(), R.array.action_list, android.R.layout.simple_spinner_dropdown_item), this); setContentView(R.layout.activity_main); if (savedInstanceState == null) { getSupportFragmentManager().beginTransaction() .replace(android.R.id.content, new FillForegroundFragment()).commit(); }/*from w w w. ja v a 2 s.c o m*/ }
From source file:com.eyekabob.AddBand.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.addband);// w w w .j a v a2s.c o m Spinner genreSpinner = (Spinner) findViewById(R.id.genreSpinner); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.genres_array, R.layout.list_item); genreSpinner.setAdapter(adapter); }
From source file:com.bar.roundedimageview.example.ExampleActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.example_activity); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); Spinner navSpinner = (Spinner) findViewById(R.id.spinner_nav); navSpinner.setAdapter(ArrayAdapter.createFromResource(navSpinner.getContext(), R.array.action_list, android.R.layout.simple_spinner_dropdown_item)); navSpinner.setOnItemSelectedListener(this); if (savedInstanceState == null) { navSpinner.setSelection(0);/*from w w w . j a va 2 s .co m*/ } }
From source file:com.sino.conerimageview.ExampleActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.example_activity); // Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); Spinner navSpinner = (Spinner) findViewById(R.id.spinner_nav); navSpinner.setAdapter(ArrayAdapter.createFromResource(navSpinner.getContext(), R.array.action_list, android.R.layout.simple_spinner_dropdown_item)); navSpinner.setOnItemSelectedListener(this); if (savedInstanceState == null) { navSpinner.setSelection(0);/*from ww w. j a va 2 s .co m*/ } }
From source file:com.michael.openexercise.mc_customview.roundimageviewdemo.roundimageviewexample.RoundedImageExampleActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.rounded_image_main_layout); getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); getActionBar().setListNavigationCallbacks(ArrayAdapter.createFromResource(getActionBar().getThemedContext(), R.array.action_list, android.R.layout.simple_spinner_dropdown_item), this); if (savedInstanceState == null) { getSupportFragmentManager().beginTransaction().replace(android.R.id.content, new RoundedFragment()) .commit();//from ww w . jav a 2 s .c om } }
From source file:com.currency.org.CurrencyConverterActivity.java
/** Called when the activity is first created. */ @Override/*from w w w .ja va 2 s. co m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Spinner s1 = (Spinner) findViewById(R.id.spinner1); Spinner s2 = (Spinner) findViewById(R.id.spinner2); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.name, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.select_dialog_singlechoice); val = getResources().getStringArray(R.array.value); s1.setAdapter(adapter); s2.setAdapter(adapter); s1.setOnItemSelectedListener(new spinOne(1)); s2.setOnItemSelectedListener(new spinOne(2)); Button b = (Button) findViewById(R.id.button1); b.setOnClickListener(new OnClickListener() { public void onClick(View v) { TextView t = (TextView) findViewById(R.id.textView4); if (from == to) { Toast.makeText(getApplicationContext(), "Invalid", 4000).show(); } else { try { s = getJson( "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.xchange%20where%20pair%20in%20(%22" + val[from] + val[to] + "%22)&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback="); JSONObject jObj; jObj = new JSONObject(s); String exResult = jObj.getJSONObject("query").getJSONObject("results").getJSONObject("rate") .getString("Rate"); t.setText(exResult); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }); }
From source file:org.androidannotations.test.efragment.MyListFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); ArrayAdapter<CharSequence> adapter; adapter = ArrayAdapter.createFromResource(getActivity(), R.array.planets_array, R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); list.setAdapter(adapter);/*from ww w. j a va2 s . c o m*/ }
From source file:com.grokkingandroid.sampleapp.samples.actionbar.actionviews.ActionViewActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); getSupportActionBar().setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); setContentView(R.layout.activity_fragment_container); int resId = R.array.spinner_without_searchview; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) { resId = R.array.spinner_with_searchview; }/* ww w .j av a 2 s.com*/ mSpinnerArray = getResources().getStringArray(resId); ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource( getSupportActionBar().getThemedContext(), resId, R.layout.sherlock_spinner_item); spinnerAdapter.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item); getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); getSupportActionBar().setListNavigationCallbacks(spinnerAdapter, new OnNavigationListener() { @Override public boolean onNavigationItemSelected(int itemPosition, long itemId) { if (itemPosition == mCurrSpinnerPos) { return true; } int pos = itemPosition; if (mSpinnerArray.length == 3) { pos++; } Fragment f = null; switch (pos) { case 0: f = SearchViewFragment.newInstance(); break; case 1: f = PlaceholderActionViewFragment.newInstance(); break; case 2: f = PreExpandedActionViewFragment.newInstance(); break; case 3: f = ExpandableActionViewFragment.newInstance(); break; } getSupportFragmentManager().beginTransaction().replace(R.id.demo_fragment_container, f).commit(); mCurrSpinnerPos = itemPosition; return true; } }); if (icicle != null) { int spinnerPos = icicle.getInt(KEY_SPINNER_POS, 0); mCurrSpinnerPos = spinnerPos; getSupportActionBar().setSelectedNavigationItem(spinnerPos); return; } Fragment fragment = null; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) { // SearchView only from API level 8 onwards fragment = SearchViewFragment.newInstance(); } else { fragment = PlaceholderActionViewFragment.newInstance(); } getSupportFragmentManager().beginTransaction().add(R.id.demo_fragment_container, fragment).commit(); }
From source file:com.secbro.qark.customintent.ChooseIntentUseCaseActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_choose_intent_use_case); final Intent customIntent = getIntent().getParcelableExtra(CreateCustomIntentActivity.CUSTOM_INTENT_EXTRA); if (customIntent == null) { throw new IllegalArgumentException("customIntent is null"); }//from w ww . j a va 2 s . c o m //intent usecase spinner usecaseSpinner = (Spinner) findViewById(R.id.intent_use_case_spinner); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.intent_use_case, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); usecaseSpinner.setAdapter(adapter); //Send intent button sendIntentButton = (Button) findViewById(R.id.activity_choose_intent_use_case_send_button); errorDialog = new AlertDialog.Builder(this).create(); errorDialog.setTitle("Error"); errorDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); sendIntentButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (usecaseSpinner.getSelectedItem() == null) { errorDialog.setMessage("Invalid intent use case"); errorDialog.show(); } else { String useCase = usecaseSpinner.getSelectedItem().toString(); switch (useCase) { case "startActivity": //TODO: Validate data for startActivity is present startActivity(customIntent); break; case "startActivityForResult": //TODO:Validate customIntent startActivityForResult(customIntent, START_ACTIVITY_FOR_RESULT); break; case "startService": //TODO:Validate customIntent startService(customIntent); break; case "bindService": //TODO: break; case "sendBroadcast": //TODO:Validate customIntent sendBroadcast(customIntent); break; case "sendOrderedBroadcast": //TODO: //sendOrderedBroadcast(customIntent); break; case "sendStickyBroadcast": //TODO:Validate customIntent sendStickyBroadcast(customIntent); break; default: break; } } } }); }
From source file:com.limecreativelabs.app.drawerlayout.DrawerLayoutActivity.java
/** * Called when the activity is first created. */// www. j a va 2s .c o m @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_drawerlayout); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mDrawerOptions = (ListView) findViewById(R.id.left_drawer); mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerOptions.setAdapter( ArrayAdapter.createFromResource(this, R.array.drawer, android.R.layout.simple_list_item_1)); mDrawerOptions.setOnItemClickListener(this); mToggle = new ActionBarDrawerToggleCompat(this, mDrawer, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { public void onDrawerClosed(View view) { getSupportActionBar().setTitle(R.string.drawer_layout); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } public void onDrawerOpened(View drawerView) { getSupportActionBar().setTitle(R.string.drawer_open); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; mToggle.setDrawerIndicatorEnabled(true); mDrawer.setDrawerListener(mToggle); }