@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.line_list); // Setup the list adapter = new IconAdapter<FileWrapper>(this, R.layout.line_list_item); ListView list = (ListView) findViewById(R.id.list); list.setAdapter(adapter); list.setOnItemClickListener(this); // Load Directory if (savedInstanceState != null) { backStack = savedInstanceState.getParcelableArrayList("BACKSTACK"); } if (backStack == null || backStack.size() == 0) { backStack = new ArrayList<BackStackItem>(); String startPath = (startDirectory == null || startDirectory.isEmpty()) ? Environment.getExternalStorageDirectory().getPath() : startDirectory; backStack.add(new BackStackItem(startPath, false)); } wrapFiles(); this.setVolumeControlStream(AudioManager.STREAM_MUSIC); }
BookmarksAdapter(ListView listView, List<Bookmark> bookmarks, boolean currentBook) { myBookmarks = bookmarks; myCurrentBook = currentBook; listView.setAdapter(this); listView.setOnItemClickListener(this); listView.setOnCreateContextMenuListener(this); }
private void buildView() { ServiceAcctInfo[] tempList = new ServiceAcctInfo[accountList.size()]; final ServiceAcctInfo[] acctList = accountList.toArray(tempList); AcctInfoAdapter adapter = new AcctInfoAdapter(this, acctList); setListAdapter(adapter); ListView lv = getListView(); lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE); lv.setOnItemClickListener( new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int pos, long id) { acctSelected(acctList[pos]); } }); }
private void UploadToDropBox() { Utilities.LogDebug("GpsMainActivity.UploadToDropBox"); final DropBoxHelper dropBoxHelper = new DropBoxHelper(getApplicationContext(), this); if (!dropBoxHelper.IsLinked()) { startActivity(new Intent("com.mendhak.gpslogger.DROPBOX_SETUP")); return; } final File gpxFolder = new File(Environment.getExternalStorageDirectory(), "GPSLogger"); if (gpxFolder.exists()) { String[] enumeratedFiles = gpxFolder.list(); List<String> fileList = new ArrayList<String>(Arrays.asList(enumeratedFiles)); Collections.reverse(fileList); final String[] files = fileList.toArray(new String[fileList.size()]); final Dialog dialog = new Dialog(this); dialog.setTitle(R.string.dropbox_upload); dialog.setContentView(R.layout.filelist); ListView thelist = (ListView) dialog.findViewById(R.id.listViewFiles); thelist.setAdapter( new ArrayAdapter<String>( getApplicationContext(), android.R.layout.simple_list_item_single_choice, files)); thelist.setOnItemClickListener( new OnItemClickListener() { public void onItemClick(AdapterView<?> av, View v, int index, long arg) { dialog.dismiss(); String chosenFileName = files[index]; Utilities.ShowProgress( GpsMainActivity.this, getString(R.string.dropbox_uploading), getString(R.string.please_wait)); dropBoxHelper.UploadFile(chosenFileName); } }); dialog.show(); } else { Utilities.MsgBox(getString(R.string.sorry), getString(R.string.no_files_found), this); } }
@Override public void onCreate(Bundle savedInstanceState) { Log.d(TAG, "onCreate"); super.onCreate(savedInstanceState); Thread.currentThread().setUncaughtExceptionHandler(this); setContentView(R.layout.main); inputView = (EditText) findViewById(R.id.input_view); inputView.setOnEditorActionListener(this); listAdapter = new ArrayAdapter<String>(this, R.layout.row); listAdapter.setNotifyOnChange(true); resultsView = (ListView) this.findViewById(R.id.results_view); resultsView.setAdapter(listAdapter); resultsView.setOnItemClickListener(this); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_contacts); findViewById(R.id.activity_contacts_add) .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { showDetails(null); } }); listAdapter = new ContactRowAdapter(this, R.layout.contact_row, null, FROM, TO, 0); ListView listView = ((ListView) findViewById(R.id.activity_contacts_list)); listView.setAdapter(listAdapter); listView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> l, View v, int p, long id) { if (WebData.Object.inConflict(listAdapter.getCursor())) { resolveConflict(p); } else { showDetails(p); } } }); new SchemaManager( this, ContactContract.SCHEMA_ID, ((ContactsApplication) getApplication()).getUser(), this) .initSchema(); }
public void setMeatToppingsView() { ListView list = (ListView) findViewById(R.id.meatToppingsView); String[] meat = {"Pepperoni", "Chicken", "Ground Beef", "Anchovies", "Bacon Bits"}; List<String> meatList = Arrays.asList(meat); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_checked, meatList); list.setAdapter(adapter); list.setClickable(true); list.setChoiceMode(list.CHOICE_MODE_MULTIPLE); list.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { CheckedTextView item = (CheckedTextView) view; if (item.isChecked()) { numMeatToppings++; } else { numMeatToppings--; } } }); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); messagesListView = (ListView) findViewById(android.R.id.list); ArrayAdapter<MessageEntry> dataAdapter = new ArrayAdapter<MessageEntry>( this, android.R.layout.simple_list_item_1, new ArrayList<MessageEntry>()); messagesListView.setAdapter(dataAdapter); messagesListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, final long id) { final MessageEntry messageEntry = (MessageEntry) messagesListView.getAdapter().getItem(position); // When clicked, show a toast with the TextView text Toast.makeText(getApplicationContext(), messageEntry.getMessage(), Toast.LENGTH_SHORT) .show(); promptForAddEdit(messageEntry); } }); findViewById(R.id.callerAddButton) .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { promptForAddEdit(null); } }); }
/** Uploads a GPS Trace to OpenStreetMap.org. */ private void UploadToOpenStreetMap() { Utilities.LogDebug("GpsMainactivity.UploadToOpenStreetMap"); if (!OSMHelper.IsOsmAuthorized(getApplicationContext())) { startActivity(OSMHelper.GetOsmSettingsIntent(getApplicationContext())); return; } final String goToOsmSettings = getString(R.string.menu_settings); final File gpxFolder = new File(Environment.getExternalStorageDirectory(), "GPSLogger"); if (gpxFolder.exists()) { FilenameFilter select = new FilenameFilter() { public boolean accept(File dir, String filename) { return filename.toLowerCase().contains(".gpx"); } }; String[] enumeratedFiles = gpxFolder.list(select); List<String> fileList = new ArrayList<String>(Arrays.asList(enumeratedFiles)); Collections.reverse(fileList); fileList.add(0, goToOsmSettings); final String[] files = fileList.toArray(new String[fileList.size()]); final Dialog dialog = new Dialog(this); dialog.setTitle(R.string.osm_pick_file); dialog.setContentView(R.layout.filelist); ListView thelist = (ListView) dialog.findViewById(R.id.listViewFiles); thelist.setAdapter( new ArrayAdapter<String>( getApplicationContext(), android.R.layout.simple_list_item_single_choice, files)); thelist.setOnItemClickListener( new OnItemClickListener() { public void onItemClick(AdapterView<?> av, View v, int index, long arg) { dialog.dismiss(); String chosenFileName = files[index]; if (chosenFileName.equalsIgnoreCase(goToOsmSettings)) { startActivity(OSMHelper.GetOsmSettingsIntent(getApplicationContext())); } else { OSMHelper osm = new OSMHelper(GpsMainActivity.this, GpsMainActivity.this); Utilities.ShowProgress( GpsMainActivity.this, getString(R.string.osm_uploading), getString(R.string.please_wait)); osm.UploadGpsTrace(chosenFileName); } } }); dialog.show(); } else { Utilities.MsgBox(getString(R.string.sorry), getString(R.string.no_files_found), this); } }
/** * Allows user to send a GPX/KML file along with location, or location only using a provider. * 'Provider' means any application that can accept such an intent (Facebook, SMS, Twitter, Email, * K-9, Bluetooth) */ private void Share() { Utilities.LogDebug("GpsMainActivity.Share"); try { final String locationOnly = getString(R.string.sharing_location_only); final File gpxFolder = new File(Environment.getExternalStorageDirectory(), "GPSLogger"); if (gpxFolder.exists()) { String[] enumeratedFiles = gpxFolder.list(); List<String> fileList = new ArrayList<String>(Arrays.asList(enumeratedFiles)); Collections.reverse(fileList); fileList.add(0, locationOnly); final String[] files = fileList.toArray(new String[fileList.size()]); final Dialog dialog = new Dialog(this); dialog.setTitle(R.string.sharing_pick_file); dialog.setContentView(R.layout.filelist); ListView thelist = (ListView) dialog.findViewById(R.id.listViewFiles); thelist.setAdapter( new ArrayAdapter<String>( getApplicationContext(), android.R.layout.simple_list_item_single_choice, files)); thelist.setOnItemClickListener( new OnItemClickListener() { public void onItemClick(AdapterView<?> av, View v, int index, long arg) { dialog.dismiss(); String chosenFileName = files[index]; final Intent intent = new Intent(Intent.ACTION_SEND); // intent.setType("text/plain"); intent.setType("*/*"); if (chosenFileName.equalsIgnoreCase(locationOnly)) { intent.setType("text/plain"); } intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.sharing_mylocation)); if (Session.hasValidLocation()) { String bodyText = getString( R.string.sharing_latlong_text, String.valueOf(Session.getCurrentLatitude()), String.valueOf(Session.getCurrentLongitude())); intent.putExtra(Intent.EXTRA_TEXT, bodyText); intent.putExtra("sms_body", bodyText); } if (chosenFileName.length() > 0 && !chosenFileName.equalsIgnoreCase(locationOnly)) { intent.putExtra( Intent.EXTRA_STREAM, Uri.fromFile(new File(gpxFolder, chosenFileName))); } startActivity(Intent.createChooser(intent, getString(R.string.sharing_via))); } }); dialog.show(); } else { Utilities.MsgBox(getString(R.string.sorry), getString(R.string.no_files_found), this); } } catch (Exception ex) { Utilities.LogError("Share", ex); } }
BookmarksAdapter(ListView listView, boolean showAddBookmarkItem) { myShowAddBookmarkItem = showAddBookmarkItem; listView.setAdapter(this); listView.setOnItemClickListener(this); listView.setOnCreateContextMenuListener(this); }