List of usage examples for android.widget SimpleAdapter SimpleAdapter
public SimpleAdapter(Context context, List<? extends Map<String, ?>> data, @LayoutRes int resource, String[] from, @IdRes int[] to)
From source file:net.reichholf.dreamdroid.activities.MovieListActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mAdapter = new SimpleAdapter(this, mMapList, R.layout.movie_list_item, new String[] { Movie.TITLE, Movie.SERVICE_NAME, Movie.FILE_SIZE_READABLE, Movie.TIME_READABLE, Movie.LENGTH },/* w w w .ja v a 2 s. co m*/ new int[] { R.id.movie_title, R.id.service_name, R.id.file_size, R.id.event_start, R.id.event_duration }); setListAdapter(mAdapter); mSelectedTags = new ArrayList<String>(); reload(); }
From source file:com.abcvoipsip.ui.prefs.CodecsFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); prefsWrapper = new PreferencesWrapper(getActivity()); initDatas();/*w w w . java2s .c om*/ setHasOptionsMenu(true); // Adapter mAdapter = new SimpleAdapter(getActivity(), codecsList, R.layout.codecs_list_item, new String[] { CODEC_NAME, CODEC_PRIORITY }, new int[] { R.id.line1, R.id.entiere_line }); mAdapter.setViewBinder(new ViewBinder() { @Override public boolean setViewValue(View view, Object data, String textRepresentation) { if (view.getId() == R.id.entiere_line) { Log.d(THIS_FILE, "Entiere line is binded "); TextView tv = (TextView) view.findViewById(R.id.line1); ImageView grabber = (ImageView) view.findViewById(R.id.icon); if ((Short) data == 0) { tv.setTextColor(Color.GRAY); grabber.setImageResource(R.drawable.ic_mp_disabled); } else { tv.setTextColor(Color.WHITE); grabber.setImageResource(R.drawable.ic_mp_move); } return true; } return false; } }); setListAdapter(mAdapter); registerForContextMenu(getListView()); }
From source file:com.nextgis.mobile.forms.CameraFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setRetainInstance(true);//www. j a v a2s . com View view = inflater.inflate(R.layout.camfragment, container, false); Button button = (Button) view.findViewById(R.id.insert_take_photo); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { onCapturePhoto(); } }); ListView photoList = (ListView) view.findViewById(R.id.poi_photos_list); adapter = new SimpleAdapter(view.getContext(), listItems, R.layout.row, new String[] { IMG_NAME, IMG_ROT, }, new int[] { R.id.image_name, R.id.image_rotation }); photoList.setAdapter(adapter); final LocationManager locationManager = (LocationManager) getActivity() .getSystemService(Context.LOCATION_SERVICE); if (currentLocation == null) { currentLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (currentLocation == null) { currentLocation = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); } } long now = System.currentTimeMillis(); declination = CompassFragment.getDeclination(currentLocation, now); sensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE); return view; }
From source file:com.rastating.droidbeard.fragments.HistoryFragment.java
@Override public void onApiRequestFinished(SickbeardAsyncTask sender, HistoricalEvent[] result) { if (activityStillExists()) { if (result != null) { ArrayList<Map<String, String>> data = new ArrayList<Map<String, String>>(result.length); for (HistoricalEvent event : result) { HashMap<String, String> item = new HashMap<String, String>(); item.put("name", String.format("%s %dx%d", event.getShowName(), event.getSeason(), event.getEpisodeNumber())); item.put("desc", String.format("%s (%s) on %s", event.getStatus(), event.getQuality(), event.getDate())); data.add(item);/*from w w w .j ava 2 s.c o m*/ } String[] from = new String[] { "name", "desc" }; int[] to = new int[] { R.id.episode, R.id.event_details }; SimpleAdapter adapter = new SimpleAdapter(getActivity(), data, R.layout.historical_event_item, from, to) { @Override public View getView(int position, View convertView, ViewGroup parent) { View view = super.getView(position, convertView, parent); if (position % 2 == 0) { view.setBackgroundResource(R.drawable.alternate_list_item_bg); } else { view.setBackgroundColor(Color.TRANSPARENT); } return view; } @Override public boolean isEnabled(int position) { return false; } }; setAdapter(adapter); showListView(); } else { showError(getString(R.string.error_fetching_history), sender.getLastException()); } } }
From source file:it.uniroma2.foundme.studente.FollowCourseActivity.java
public static void populateView(String[] result) { courses = new String[result.length]; System.arraycopy(result, 0, courses, 0, result.length); List<Map<String, String>> data = new ArrayList<Map<String, String>>(); for (int i = 0; i < result.length; i++) { Map<String, String> datum = new HashMap<String, String>(2); if (i == 0 && result[0].equalsIgnoreCase(Variables_it.NO_COURSE)) { datum.put(Variables_it.COURSE, result[0]); datum.put(Variables_it.PROF, ""); data.add(datum);//from w w w . ja v a 2 s . c o m break; } else { String[] items = result[i].split(","); String ap = items[0] + items[1]; datum.put(Variables_it.COURSE, ap); datum.put(Variables_it.PROF, items[2]); data.add(datum); } } //creo l'adapter final SimpleAdapter adapter = new SimpleAdapter(context, data, android.R.layout.simple_list_item_2, new String[] { Variables_it.COURSE, Variables_it.PROF }, new int[] { android.R.id.text1, android.R.id.text2 }); lvTuttiCorsi.setAdapter(adapter); lvTuttiCorsi.setTextFilterEnabled(true); swipeFollow.setColorSchemeColors(0xff429874, 0xffffffff, 0xff429874, 0xffffffff); swipeFollow.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { swipeFollow.setRefreshing(true); (new Handler()).postDelayed(new Runnable() { @Override public void run() { swipeFollow.setRefreshing(false); try { getCourse(false); } catch (ExecutionException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } } }, 3000); } }); lvTuttiCorsi.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (!courses[position].equalsIgnoreCase(Variables_it.NO_COURSE)) alertMessage(courses[position]); } }); lvTuttiCorsi.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView absListView, int i) { } @Override public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (firstVisibleItem == 0) swipeFollow.setEnabled(true); else swipeFollow.setEnabled(false); } }); etFilter.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s.toString()); } }); }
From source file:com.privacity.ListaPerfilActivity.java
@Override protected void onResume() { super.onResume(); Eventos = new ArrayList<HashMap<String, String>>(); com = new ConexionSiabra(this); JSONObject jsonObject = com.getListaPerfiles(); String[] perfiles = this.getIntent().getStringArrayExtra("perfiles"); String[] perfilesCodigo = this.getIntent().getStringArrayExtra("perfilesCodigo"); if (!jsonObject.has("Error") && !jsonObject.has("detail")) { try {/* ww w.jav a2s.com*/ perfiles = new String[jsonObject.length()]; perfilesCodigo = new String[jsonObject.length()]; for (int i = 0; i < jsonObject.length(); i++) { JSONArray array = jsonObject.getJSONArray(String.valueOf(i)); perfiles[i] = array.getString(0); perfilesCodigo[i] = array.getString(1); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); Log.wtf("Error", e); } for (int i = 0; i < perfiles.length; i++) { HashMap<String, String> datosEvento = new HashMap<String, String>(); datosEvento.put("username", perfiles[i]); datosEvento.put("codigo", perfilesCodigo[i]); Eventos.add(datosEvento); } } // IF no hay error else { Dialog dialogo = new Dialog(this); dialogo.setTitle(getResources().getString(R.string.errorDeConexion)); dialogo.show(); } // PINTA TODAS LAS FILAS SimpleAdapter ListadoAdapter = new SimpleAdapter(this, Eventos, R.layout.row, from, to); setListAdapter(ListadoAdapter); }
From source file:com.dsi.ant.antplus.pluginsampler.watchdownloader.Activity_WatchScanList.java
/** Called when the activity is first created. */ @Override// w ww .ja va 2 s .com protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_device_list); tv_status = (TextView) findViewById(R.id.textView_Status); deviceList_Display = new ArrayList<Map<String, String>>(); adapter_deviceList_Display = new SimpleAdapter(this, deviceList_Display, android.R.layout.simple_list_item_2, new String[] { "title", "desc" }, new int[] { android.R.id.text1, android.R.id.text2 }); ListView listView_Devices = (ListView) findViewById(R.id.listView_deviceList); listView_Devices.setAdapter(adapter_deviceList_Display); //Set the list to download the data for the selected device and display it. listView_Devices.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, final int pos, long id) { if (!bDevicesInList || watchPcc == null) return; final CharSequence[] downloadOptions = { "All Activities", "New Activities", "Wait For New Activities" }; AlertDialog.Builder builder = new AlertDialog.Builder(Activity_WatchScanList.this); builder.setTitle("Download..."); builder.setItems(downloadOptions, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int downloadSelection) { antFsProgressDialog = new ProgressDialog(Activity_WatchScanList.this); antFsProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); antFsProgressDialog.setMessage("Sending Request..."); antFsProgressDialog.setCancelable(false); antFsProgressDialog.setIndeterminate(false); fitFileList = new ArrayList<FitFile>(); if (downloadSelection == 0) // download all { if (watchPcc.requestDownloadAllActivities(deviceInfoArray[pos].getDeviceUUID(), new DownloadActivitiesFinished(pos), new FileDownloadedReceiver(), new AntFsUpdateReceiver())) { antFsProgressDialog.show(); } } else if (downloadSelection == 1) // download new { if (watchPcc.requestDownloadNewActivities(deviceInfoArray[pos].getDeviceUUID(), new DownloadActivitiesFinished(pos), new FileDownloadedReceiver(), new AntFsUpdateReceiver())) { antFsProgressDialog.show(); } } else if (downloadSelection == 2) { boolean reqSubmitted = watchPcc.listenForNewActivities( deviceInfoArray[pos].getDeviceUUID(), new IDownloadActivitiesFinishedReceiver() { @Override public void onNewDownloadActivitiesFinished(AntFsRequestStatus status) { //Only received on cancel right now, only thing to do is cancel dialog, already taken care of below } }, new FileDownloadedReceiver() { @Override public void onNewFitFileDownloaded(FitFile downloadedFitFile) { super.onNewFitFileDownloaded(downloadedFitFile); //Now show each file as we get it List<FitFile> newActivityOnly = new ArrayList<FitFile>(fitFileList); fitFileList.clear(); final Dialog_WatchData dataDialog = new Dialog_WatchData( deviceInfoArray[pos], newActivityOnly); runOnUiThread(new Runnable() { @Override public void run() { dataDialog.show(getSupportFragmentManager(), "DeviceData"); } }); } }); //Once the listener is started we leave this dialog open until it is cancelled //Note: Because the listener is an asynchronous process, you do not need to block the UI like the sample app does with this, you can leave it invisible to the user if (reqSubmitted) { AlertDialog.Builder builder = new AlertDialog.Builder(Activity_WatchScanList.this); LayoutInflater inflater = Activity_WatchScanList.this.getLayoutInflater(); // Inflate and set the layout for the dialog // Pass null as the parent view because its going in the dialog layout View detailsView = inflater.inflate(R.layout.dialog_progresswaiter, null); TextView textView_status = (TextView) detailsView .findViewById(R.id.textView_Status); textView_status.setText("Waiting for new activities on " + deviceInfoArray[pos].getDisplayName() + "..."); builder.setView(detailsView); builder.setNegativeButton("Cancel", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //Let onCancelListener take care of business dialog.cancel(); } }); builder.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (watchPcc != null) { watchPcc.cancelListenForNewActivities( deviceInfoArray[pos].getDeviceUUID()); } } }); AlertDialog waitDialog = builder.create(); waitDialog.show(); } } } }); AlertDialog alert = builder.create(); alert.show(); } }); resetPcc(); }
From source file:org.ohmage.prompt.multichoice.MultiChoicePrompt.java
@Override public View getView(Context context) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); ListView listView = (ListView) inflater.inflate(R.layout.prompt_multi_choice, null); listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); String[] from = new String[] { "value" }; int[] to = new int[] { android.R.id.text1 }; List<HashMap<String, String>> data = new ArrayList<HashMap<String, String>>(); for (int i = 0; i < mChoices.size(); i++) { HashMap<String, String> map = new HashMap<String, String>(); map.put("key", mChoices.get(i).key); map.put("value", mChoices.get(i).label); data.add(map);/* w w w .j a v a 2 s.c o m*/ } SimpleAdapter adapter = new SimpleAdapter(context, data, R.layout.multi_choice_list_item, from, to); adapter.setViewBinder(new ViewBinder() { @Override public boolean setViewValue(View view, Object data, String textRepresentation) { ((CheckedTextView) view).setText((String) data); return true; } }); listView.setAdapter(adapter); if (mSelectedIndexes.size() > 0) { for (int index : mSelectedIndexes) { if (index >= 0 && index < mChoices.size()) listView.setItemChecked(index, true); } } listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { //SparseBooleanArray checkItemPositions = ((ListView)parent).getCheckedItemPositions(); if (((ListView) parent).isItemChecked(position)) { mSelectedIndexes.add(Integer.valueOf(position)); } else { mSelectedIndexes.remove(Integer.valueOf(position)); } } }); return listView; }
From source file:org.adaway.ui.adware.AdwareFragment.java
/** * Display the installed adware.//from w w w. j a va 2 s.c om * * @param data The adware to show. */ private void displayAdware(List<AdwareInstall> data) { // Create adapter String[] from = new String[] { AdwareInstall.APPLICATION_NAME_KEY, AdwareInstall.PACKAGE_NAME_KEY }; int[] to = new int[] { R.id.checkbox_list_text, R.id.checkbox_list_subtext }; SimpleAdapter adapter = new SimpleAdapter(this.getContext(), data, R.layout.list_two_entries, from, to); // Update list adapter.notifyDataSetChanged(); // Show the list this.mListView.setAdapter(adapter); this.mStatusText.setVisibility(View.GONE); this.mListView.setVisibility(View.VISIBLE); }
From source file:net.reichholf.dreamdroid.activities.SearchEpgActivity.java
/** * Initializes the <code>SimpleListAdapter</code> *///from ww w .j av a2 s . c om private void setAdapter() { mAdapter = new SimpleAdapter(this, mMapList, R.layout.epg_multi_service_list_item, new String[] { Event.SERVICE_NAME, Event.EVENT_TITLE, Event.EVENT_START_READABLE, Event.EVENT_DURATION_READABLE }, new int[] { R.id.service_name, R.id.event_title, R.id.event_start, R.id.event_duration }); setListAdapter(mAdapter); }