List of usage examples for android.widget ArrayAdapter ArrayAdapter
public ArrayAdapter(@NonNull Context context, @LayoutRes int resource, @IdRes int textViewResourceId, @NonNull List<T> objects)
From source file:com.groundupworks.wings.gcp.GoogleCloudPrintSettingsActivity.java
private void onPrinterDetails(final Response response) { if (response.getStatus() == HttpURLConnection.HTTP_OK) { final List<MediaSize> sizes = parseMediaSizes(response); final boolean hasMediaSize = !sizes.isEmpty(); if (hasMediaSize) { mMediaSpinner.setAdapter(new ArrayAdapter<MediaSize>(GoogleCloudPrintSettingsActivity.this, R.layout.gcp_settings_spinner_item, R.id.activity_main_spinner_item_text, sizes)); }//from w w w . ja v a 2s . c om mMediaSpinner.setVisibility(hasMediaSize ? View.VISIBLE : View.GONE); } }
From source file:info.semanticsoftware.semassist.android.activity.SemanticAssistantsActivity.java
/** * Reads the available assistants from the server response and * populates the list on the UI. /*from w ww . j a va2s .com*/ */ private void populateServicesList() { if (servicesList != null) { Toast.makeText(this, "Connected to " + serverURL, Toast.LENGTH_LONG).show(); String[] values = null; List<String> names = new ArrayList<String>(); for (int i = 0; i < servicesList.getItem().size(); i++) { names.add(servicesList.getItem().get(i).getServiceName()); } values = names.toArray(new String[names.size()]); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.row, R.id.label, values); setListAdapter(adapter); } else { Toast.makeText(this, "No assistants found! The server may be offline.", Toast.LENGTH_LONG).show(); } }
From source file:com.google.cast.samples.games.codelab.DrawingFragment.java
/** * Set the list of words to display for guessing. */// w w w . jav a 2 s .co m private void resetWords(List<String> words) { if (words != null) { ListView list = (ListView) getView().findViewById(R.id.listView); ArrayAdapter<String> adapter = new ArrayAdapter<String>(getView().getContext(), R.layout.list_item, R.id.text, words); list.setAdapter(adapter); } }
From source file:most.voip.example.ws_config.MainActivity.java
private void initializeGUI() { setContentView(R.layout.activity_main); ListView listView = (ListView) findViewById(R.id.listOperations); ListView buddiesView = (ListView) findViewById(R.id.listBuddies); this.infoArray = new ArrayList<String>(); this.arrayAdapter = new ArrayAdapter<String>(this, R.layout.row, R.id.textViewList, this.infoArray); listView.setAdapter(this.arrayAdapter); buddiesView.setOnItemClickListener(new OnItemClickListener() { @Override/*w w w . ja v a 2 s . com*/ public void onItemClick(AdapterView<?> parent, View view, int position, long id) { EditText txtExtension = (EditText) findViewById(R.id.txtExtension); txtExtension.setText(buddiesArray.get(position).getExtension()); } }); this.buddiesArray = new ArrayList<IBuddy>(); this.buddyArrayAdapter = new BuddyArrayAdapter(this, R.layout.buddy_row, this.buddiesArray); buddiesView.setAdapter(this.buddyArrayAdapter); this.setupButtons(); //this.addInfoLine("Most Voip Lib Test Example 1"); }
From source file:com.aknowledge.v1.automation.RemoteActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_remote); myApp = (PyHomeController) getApplication(); final ActionBar actionBar = getActionBar(); actionBar.setDisplayShowTitleEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); actionBar.setListNavigationCallbacks( // Specify a SpinnerAdapter to populate the dropdown list. new ArrayAdapter<String>(actionBar.getThemedContext(), android.R.layout.simple_list_item_1, android.R.id.text1, new String[] { "All" }), this); }
From source file:abanoubm.dayra.main.Main.java
private void sign() { String inpath;/*from ww w . j a v a2s . c om*/ if (android.os.Build.VERSION.SDK_INT >= 17) { inpath = getApplicationContext().getApplicationInfo().dataDir + "/databases/"; } else { inpath = "/data/data/" + getApplicationContext().getPackageName() + "/databases/"; } File folder = new File(inpath); File[] listOfFiles = folder.listFiles(); if (listOfFiles == null || listOfFiles.length == 0) { Toast.makeText(getApplicationContext(), R.string.msg_no_dayra, Toast.LENGTH_SHORT).show(); } else { ArrayList<String> names = new ArrayList<>(listOfFiles.length); for (File file : listOfFiles) { if (!file.getName().contains("journal")) names.add(file.getName()); } LayoutInflater li = LayoutInflater.from(getApplicationContext()); View signView = li.inflate(R.layout.dialogue_signin, null, false); final AlertDialog ad = new AlertDialog.Builder(Main.this).setCancelable(true).create(); ad.setView(signView, 0, 0, 0, 0); ad.show(); ListView nameslv = (ListView) signView.findViewById(R.id.databases_lv); nameslv.setAdapter(new ArrayAdapter<>(getApplicationContext(), R.layout.item_string, R.id.item, names)); nameslv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String str = (String) parent.getItemAtPosition(position); new SignTask().execute(str); ad.dismiss(); } }); } }
From source file:org.nla.tarotdroid.lib.ui.GameSetHistoryActivity.java
/** * Manage click on GameSet./* w w w . jav a 2s . com*/ * * @param pos */ private void onListItemClick(final int pos) { final GameSet gameSet = (GameSet) getListAdapter().getItem(pos); final Item[] items = AppContext.getApplication().isAppLimited() ? limitedItems : allItems; ListAdapter adapter = new ArrayAdapter<Item>(this, android.R.layout.select_dialog_item, android.R.id.text1, items) { @Override public View getView(int position, View convertView, ViewGroup parent) { // User super class to create the View View v = super.getView(position, convertView, parent); TextView tv = (TextView) v.findViewById(android.R.id.text1); // Put the image on the TextView tv.setCompoundDrawablesWithIntrinsicBounds(items[position].icon, 0, 0, 0); // Add margin between image and text (support various screen // densities) int dp5 = (int) (5 * getResources().getDisplayMetrics().density + 0.5f); tv.setCompoundDrawablePadding(dp5); return v; } }; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(String.format(this.getString(R.string.lblGameSetHistoryActivityMenuTitle), new SimpleDateFormat("dd/MM/yy").format(gameSet.getCreationTs()))); builder.setAdapter(adapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int itemIndex) { Item item = items[itemIndex]; if (item.itemType == Item.ItemTypes.publishOnFacebook) { // check for active internet connexion first // see post // http://stackoverflow.com/questions/2789612/how-can-i-check-whether-an-android-device-is-connected-to-the-web ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService( Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isConnected()) { if (gameSet.getGameCount() == 0) { Toast.makeText(GameSetHistoryActivity.this, R.string.lblFacebookImpossibleToPublishGamesetWithNoGame, Toast.LENGTH_SHORT) .show(); } else if (!AppContext.getApplication().getNotificationIds().isEmpty()) { Toast.makeText(GameSetHistoryActivity.this, R.string.lblFacebookGamesetBeingPublished, Toast.LENGTH_SHORT).show(); } else { tempGameSet = gameSet; // // TODO Improve in later version // ShortenUrlTask shortenUrlTask = new // ShortenUrlTask(FacebookHelper.buildGameSetUrl(tempGameSet)); // shortenUrlTask.setCallback(urlShortenedCallback); // shortenUrlTask.execute(); startPostProcess(); } } else { Toast.makeText(GameSetHistoryActivity.this, getString(R.string.titleInternetConnexionNecessary), Toast.LENGTH_LONG).show(); } } else if (item.itemType == Item.ItemTypes.publishOnTwitter) { Toast.makeText(GameSetHistoryActivity.this, "TODO: Publish on twitter", Toast.LENGTH_LONG) .show(); Intent intent = new Intent(GameSetHistoryActivity.this, TwitterConnectActivity.class); startActivity(intent); } else if (item.itemType == Item.ItemTypes.remove) { RemoveGameSetDialogClickListener removeGameSetDialogClickListener = new RemoveGameSetDialogClickListener( gameSet); AlertDialog.Builder builder = new AlertDialog.Builder(GameSetHistoryActivity.this); builder.setTitle(GameSetHistoryActivity.this.getString(R.string.titleRemoveGameSetYesNo)); builder.setMessage(Html.fromHtml( GameSetHistoryActivity.this.getText(R.string.msgRemoveGameSetYesNo).toString())); builder.setPositiveButton(GameSetHistoryActivity.this.getString(R.string.btnOk), removeGameSetDialogClickListener); builder.setNegativeButton(GameSetHistoryActivity.this.getString(R.string.btnCancel), removeGameSetDialogClickListener).show(); builder.setIcon(android.R.drawable.ic_dialog_alert); } else if (item.itemType == Item.ItemTypes.transferOverBluetooth) { if (!GameSetHistoryActivity.this.bluetoothHelper.isBluetoothEnabled()) { Toast.makeText(GameSetHistoryActivity.this, GameSetHistoryActivity.this.getString(R.string.msgActivateBluetooth), Toast.LENGTH_LONG).show(); } try { // make sure at least one device was discovered if (GameSetHistoryActivity.this.bluetoothHelper.getBluetoothDeviceCount() == 0) { Toast.makeText(GameSetHistoryActivity.this, GameSetHistoryActivity.this.getString(R.string.msgRunDiscoverDevicesFirst), Toast.LENGTH_LONG).show(); } // display devices and download final String[] items = GameSetHistoryActivity.this.bluetoothHelper .getBluetoothDeviceNames(); AlertDialog.Builder builder = new AlertDialog.Builder(GameSetHistoryActivity.this); builder.setTitle(GameSetHistoryActivity.this.getString(R.string.lblSelectBluetoothDevice)); builder.setItems(items, new BluetoothDeviceClickListener(gameSet, items)); AlertDialog alert = builder.create(); alert.show(); } catch (Exception e) { AuditHelper.auditError(ErrorTypes.gameSetHistoryActivityError, e, GameSetHistoryActivity.this); } } else if (item.itemType == Item.ItemTypes.exportToExcel) { try { if (!AppContext.getApplication().isAppLimited()) { ExportToExcelTask task = new ExportToExcelTask(GameSetHistoryActivity.this, progressDialog); task.setCallback(excelExportCallback); task.execute(gameSet); } } catch (Exception e) { Toast.makeText( GameSetHistoryActivity.this, AppContext.getApplication().getResources() .getText(R.string.msgGameSetExportError).toString() + e.getMessage(), Toast.LENGTH_LONG).show(); AuditHelper.auditError(ErrorTypes.excelFileStorage, e); } } else if (item.itemType == Item.ItemTypes.edit) { // SharedPreferences preferences = // PreferenceManager.getDefaultSharedPreferences(GameSetHistoryActivity.this); // set selected gameset as session gameset // AppContext.getApplication().getBizService().setGameSet(gameSet); // // Get non DAL stored parameters property from shared // preferences // UIHelper.fillNonComputationPreferences(gameSet.getGameSetParameters(), // preferences); // start tab gameset activity Intent intent = new Intent(GameSetHistoryActivity.this, TabGameSetActivity.class); intent.putExtra(ActivityParams.PARAM_GAMESET_ID, gameSet.getId()); GameSetHistoryActivity.this.startActivityForResult(intent, RequestCodes.DISPLAY_WITH_FACEBOOK); } } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:activities.PaintActivity.java
public void cameraClicked() { String[] pictureOptions = getResources().getStringArray(array.picture_choose); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.select_dialog_item, android.R.id.text1, pictureOptions); new AlertDialog.Builder(this).setTitle(string.picturechooser_title) .setAdapter(adapter, new DialogInterface.OnClickListener() { @Override/*from ww w . j a v a 2 s.com*/ public void onClick(DialogInterface dialogInterface, int i) { switch (i) { case 0: //Camara //Toma la foto PaintUtility.launchCameraIntent(PaintActivity.this); painter.openedCamera(); break; case 1: //Gallera PaintUtility.launchLibraryIntent(PaintActivity.this); break; } } }).setCancelable(true).show(); }