List of usage examples for android.widget ArrayAdapter ArrayAdapter
public ArrayAdapter(@NonNull Context context, @LayoutRes int resource, @NonNull List<T> objects)
From source file:de.awisus.refugeeaidleipzig.views.signup.FragmentSignup.java
/** * Private method that creates an Array Adapter the spinner uses to show accommodation names *///from www .j a va 2 s. com private void initSpinnerAdapter() { LinkedList<Unterkunft> unterkuenfte; unterkuenfte = model.getUnterkuenfte().asList(); Collections.sort(unterkuenfte); ArrayAdapter<Unterkunft> adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item, unterkuenfte); // 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 spUnterkunft.setAdapter(adapter); }
From source file:com.nonstop.android.SoC.Facebook.Hackbook.java
/** Called when the activity is first created. */ @Override//from ww w . j ava 2 s . c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (APP_ID == null) { Util.showAlert(this, "Warning", "Facebook Applicaton ID must be " + "specified before running this example: see FbAPIs.java"); return; } setContentView(R.layout.main); mHandler_facebook = new Handler(); mText = (TextView) Hackbook.this.findViewById(R.id.txt); mUserPic = (ImageView) Hackbook.this.findViewById(R.id.user_pic); // Create the Facebook Object using the app id. Utility.mFacebook = new Facebook(APP_ID); // Instantiate the asynrunner object for asynchronous api calls. Utility.mAsyncRunner = new AsyncFacebookRunner(Utility.mFacebook); mLoginButton = (LoginButton) findViewById(R.id.login); // restore session if one exists SessionStore.restore(Utility.mFacebook, this); SessionEvents.addAuthListener(new FbAPIsAuthListener()); SessionEvents.addLogoutListener(new FbAPIsLogoutListener()); /* * Source Tag: login_tag */ mLoginButton.init(this, AUTHORIZE_ACTIVITY_RESULT_CODE, Utility.mFacebook, permissions); if (Utility.mFacebook.isSessionValid()) { requestUserData(); } list = (ListView) findViewById(R.id.main_list); list.setOnItemClickListener(this); list.setAdapter(new ArrayAdapter<String>(this, R.layout.main_list_item, main_items)); }
From source file:com.microsoft.live.sample.ExplorerActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.explorer);//from w w w . j a v a 2s . c o m LiveSdkSampleApplication app = (LiveSdkSampleApplication) getApplication(); mConnectClient = app.getConnectClient(); mOperationListener = new OperationListener(); mResponseBodyText = (EditText) findViewById(R.id.responseBodyText); mPathText = (EditText) findViewById(R.id.pathText); mRequestBodyText = (EditText) findViewById(R.id.requestBodyText); mRequestBodyTextView = (TextView) findViewById(R.id.requestBodyTextView); final Spinner httpMethodSpinner = (Spinner) findViewById(R.id.httpMethodSpinner); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, HTTP_METHODS); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); httpMethodSpinner.setAdapter(adapter); httpMethodSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { switch (position) { case GET: case DELETE: hideRequestBody(); break; case POST: case PUT: showRequestBody(); break; default: { makeToast("Unknown HTTP method selected: " + httpMethodSpinner.getSelectedItem().toString()); break; } } } @Override public void onNothingSelected(AdapterView<?> parent) { // Do nothing. } }); findViewById(R.id.submitButton).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String path = mPathText.getText().toString(); String bodyString = mRequestBodyText.getText().toString(); if (TextUtils.isEmpty(path)) { makeToast("Path must not be empty."); return; } int selectedPosition = httpMethodSpinner.getSelectedItemPosition(); boolean httpMethodRequiresBody = selectedPosition == POST || selectedPosition == PUT; if (httpMethodRequiresBody && TextUtils.isEmpty(bodyString)) { makeToast("Request body must not be empty."); return; } mProgressDialog = showProgressDialog("Loading. Please wait..."); switch (selectedPosition) { case GET: { mConnectClient.getAsync(path, mOperationListener); break; } case DELETE: { mConnectClient.deleteAsync(path, mOperationListener); break; } case POST: { mConnectClient.postAsync(path, bodyString, mOperationListener); break; } case PUT: { mConnectClient.putAsync(path, bodyString, mOperationListener); break; } default: { makeToast("Unknown HTTP method selected: " + httpMethodSpinner.getSelectedItem().toString()); break; } } } }); }
From source file:es.uniovi.imovil.fcrtrainer.highscores.HighscoresFragment.java
private void initializeExerciseSpinner() { // La idea de esta funcin es crear los elementos del spinner utilizando // los arrays definidos en los recursos mExercises = new ArrayList<Exercise>(); addExerciseModule(mExercises, R.array.codes); addExerciseModule(mExercises, R.array.digital_systems); addExerciseModule(mExercises, R.array.networks); ArrayAdapter<Exercise> adapter = new ArrayAdapter<Exercise>(getActivity(), android.R.layout.simple_spinner_item, mExercises); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mExerciseSpinner = (Spinner) mRootView.findViewById(R.id.spinner_exercise); mExerciseSpinner.setAdapter(adapter); mExerciseSpinner.setOnItemSelectedListener(this); }
From source file:com.hybris.mobile.app.commerce.fragment.CheckoutFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mPaymentsDetails = new ArrayList<>(); mAddPayment = view.findViewById(R.id.checkout_add_payment); mPaymentSpinner = (Spinner) view.findViewById(R.id.checkout_account_payment_spinner); mPaymentAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_dropdown_item, new ArrayList<String>()); mPaymentSpinner.setAdapter(mPaymentAdapter); mPaymentSpinner.setOnItemSelectedListener(mPaymentSpinnerListener); mAddPayment.setOnClickListener(new View.OnClickListener() { @Override/* w ww.ja va 2s. co m*/ public void onClick(View v) { showCreatePaymentView(); } }); }
From source file:com.zirconi.huaxiaclient.TableActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.table_layout); dialog = new ProgressDialog(this); dialog.setTitle(""); dialog.setMessage(""); dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); dialog.show();/*from w w w . j av a 2 s . c o m*/ SharedPreferences tmp = this.getSharedPreferences("LOGIN", MODE_PRIVATE); NUM = this.getIntent().getStringExtra("NUM"); T_1 = new String[DAY_PER_WEEK]; T_2 = new String[DAY_PER_WEEK]; T_3 = new String[DAY_PER_WEEK]; T_4 = new String[DAY_PER_WEEK]; item_1 = new ArrayList<Map<String, String>>(); item_2 = new ArrayList<Map<String, String>>(); item_3 = new ArrayList<Map<String, String>>(); item_4 = new ArrayList<Map<String, String>>(); lv = (ListView) this.findViewById(R.id.table_lv_week); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, WEEK); lv.setAdapter(adapter); if (tmp.getBoolean("TEL", true)) { this.SERVER = SharedApplication.HTTP_TEL_ADDR; } else { this.SERVER = SharedApplication.HTTP_CER_ADDR; } FinalPAGE = SERVER + TABLE_PAGE + SharedApplication.STU_NUM + NUM + EXTRA; Log.d("FINALPAGE", FinalPAGE); TASK = new AsyncTable(); TASK.execute(FinalPAGE); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Log.d("POSITION", Integer.toString(position)); switch (position) { case 0: Intent intent_1 = new Intent(TableActivity.this, DetailActivity.class); intent_1.putExtra("day", 0); startActivity(intent_1); break; case 1: Intent intent_2 = new Intent(TableActivity.this, DetailActivity.class); intent_2.putExtra("day", 1); startActivity(intent_2); break; case 2: Intent intent_3 = new Intent(TableActivity.this, DetailActivity.class); intent_3.putExtra("day", 2); startActivity(intent_3); break; case 3: Intent intent_4 = new Intent(TableActivity.this, DetailActivity.class); intent_4.putExtra("day", 3); startActivity(intent_4); break; case 4: Intent intent_5 = new Intent(TableActivity.this, DetailActivity.class); intent_5.putExtra("day", 4); startActivity(intent_5); break; case 5: Intent intent_6 = new Intent(TableActivity.this, DetailActivity.class); intent_6.putExtra("day", 5); startActivity(intent_6); break; case 6: Intent intent_7 = new Intent(TableActivity.this, DetailActivity.class); intent_7.putExtra("day", 6); startActivity(intent_7); break; } } }); }
From source file:com.facebook.android.Hackbook.java
/** Called when the activity is first created. */ @Override//from ww w . j av a 2 s . c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (APP_ID == null) { Util.showAlert(this, "Warning", "Facebook Applicaton ID must be " + "specified before running this example: see FbAPIs.java"); return; } setContentView(R.layout.main); mHandler = new Handler(); mText = (TextView) Hackbook.this.findViewById(R.id.txt); mUserPic = (ImageView) Hackbook.this.findViewById(R.id.user_pic); // Create the Facebook Object using the app id. Utility.mFacebook = new Facebook(APP_ID); // Instantiate the asynrunner object for asynchronous api calls. Utility.mAsyncRunner = new AsyncFacebookRunner(Utility.mFacebook); mLoginButton = (LoginButton) findViewById(R.id.login); // restore session if one exists SessionStore.restore(Utility.mFacebook, this); SessionEvents.addAuthListener(new FbAPIsAuthListener()); SessionEvents.addLogoutListener(new FbAPIsLogoutListener()); /* * Source Tag: login_tag */ mLoginButton.init(this, AUTHORIZE_ACTIVITY_RESULT_CODE, Utility.mFacebook, permissions); if (Utility.mFacebook.isSessionValid()) { requestUserData(); } list = (ListView) findViewById(R.id.main_list); list.setOnItemClickListener(this); list.setAdapter(new ArrayAdapter<String>(this, R.layout.main_list_item, main_items)); }
From source file:com.example.android.bluetoothchat.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (savedInstanceState == null) { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); fragment = new BluetoothChatFragment(); transaction.replace(R.id.sample_content_fragment, fragment); transaction.commit();// www .j av a 2s. c o m } musiclist = (ListView) findViewById(R.id.listview); JSONDecode(test2, 5, levelCounter, "-1"); for (int p = 0; p < numChrildren; p++) { String pid = folder[p][0]; initPIDfromChrildren(pid, p); } initPIDfromFile(); getPIDAllMemNameAndId("-1"); //root PID is "-1" // adMusicList = ArrayAdapter.createFromResource(this, R.array.weekday, // android.R.layout.simple_list_item_1); adMusicList = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, myPIDMemList); musiclist.setAdapter(adMusicList); musiclist.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String id_here = myPIDMemIdList.get(position); idcommand = "ID_" + id_here + "\r\n"; Toast.makeText(MainActivity.this, "id_here:" + id_here, Toast.LENGTH_LONG).show(); getPIDAllMemNameAndId(id_here); adMusicList.notifyDataSetChanged(); // String track = ((TextView) view).getText().toString(); // Toast.makeText(MainActivity.this, myPIDMemList.get(0), Toast.LENGTH_LONG).show(); } // Bundle bundle = new Bundle(); // bundle.putString(); }); }
From source file:net.heroicefforts.viable.android.BugReporterActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.bug_report_activity); ((Button) findViewById(R.id.ReportBugButton)).setOnClickListener(clickListener); ((Button) findViewById(R.id.DetailsButton)).setOnClickListener(clickListener); appNameSpinner = (Spinner) findViewById(R.id.AppNameSpinner); typeSpinner = (Spinner) findViewById(R.id.IssueTypeSpinner); summaryText = (TextView) findViewById(R.id.BugSummaryEditText); descriptionText = (TextView) findViewById(R.id.BugDescriptionEditText); detailsTextView = (TextView) findViewById(R.id.BugDetailsTextView); detailsButton = (Button) findViewById(R.id.DetailsButton); detailsScroll = (View) findViewById(R.id.BugDetailsScrollView); factory = new RepositoryFactory(this); List<String> appNames = new ArrayList<String>(); appNames.add(getString(R.string.choose_one)); appNames.addAll(factory.getApplicationNames()); appNameSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, appNames)); appNameSpinner.setOnItemSelectedListener(appNameSelected); Set<? extends IssueResource> resources = factory.getRepository(appNames.get(1)).getDefaultStates(); typeSpinner.setAdapter(new IssueSelectionAdapter(this, resources)); detailsButton.setVisibility(View.INVISIBLE); }
From source file:it.crs4.most.ehrlib.widgets.DvCodedTextWidget.java
/** * Setup spinner./*from w ww . j av a 2 s. c o m*/ */ private void setupSpinner() { this.spinner = (Spinner) _root_view.findViewById(R.id.spinnerState); adapter = new ArrayAdapter<String>(_context, R.layout.spinner_item, getOptions()); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { currentSelectionIndex = position; } @Override public void onNothingSelected(AdapterView<?> parent) { } }); }