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:com.acrylicgoat.scrumnotes.DailyNotesActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_dailynotes); aBar = getActionBar();/*w w w. j a va 2 s .c om*/ aBar.setTitle(getString(R.string.app_name)); aBar.setDisplayHomeAsUpEnabled(true); //goals = (EditText) findViewById(R.id.editGoals); note = (EditText) findViewById(R.id.editDaily); Display d = getWindowManager().getDefaultDisplay(); if (isTabletDevice(d, this)) { if (d.getWidth() < d.getHeight()) { //in portrait so give more lines note.setLines(20); } else { note.setLines(11); } } getNotes(); String[] items = getResources().getStringArray(R.array.nav_list); setDrawer(items); drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); drawerList = (ListView) findViewById(R.id.left_drawer); SimpleAdapter sAdapter = new SimpleAdapter(this, navTitles, R.layout.nav_drawer, from, to); // Set the adapter for the list view //drawerList.setAdapter(new ArrayAdapter<String>(this,R.layout.drawer_list_item, navTitles)); // Set the list's click listener drawerList.setOnItemClickListener(new DrawerItemClickListener()); drawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ drawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description for accessibility */ R.string.drawer_close /* "close drawer" description for accessibility */ ) { public void onDrawerClosed(View view) { getActionBar().setTitle(getString(R.string.app_name)); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } public void onDrawerOpened(View drawerView) { getActionBar().setTitle(getString(R.string.app_name)); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; drawerToggle.setDrawerIndicatorEnabled(true); drawerToggle.syncState(); drawerLayout.setDrawerListener(drawerToggle); aBar.setDisplayHomeAsUpEnabled(true); aBar.setHomeButtonEnabled(true); drawerList.setAdapter(sAdapter); }
From source file:com.tritop.androsense2.fragments.SensorsList.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { getAvailableSensors();//ww w. j a v a 2s .c om mListAdapter = new SimpleAdapter(getActivity(), itemList, R.layout.list_item_layout, boundRows, boundViews); setListAdapter(mListAdapter); return super.onCreateView(inflater, container, savedInstanceState); }
From source file:org.exoplatform.shareextension.AccountsFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); ArrayList<Map<String, ExoAccount>> data = new ArrayList<Map<String, ExoAccount>>(accounts.size()); for (ExoAccount account : accounts) { Map<String, ExoAccount> map = new HashMap<String, ExoAccount>(); map.put("ACCOUNT_DATA", account); data.add(map);//from ww w . j a v a2s . co m } String[] from = { "ACCOUNT_DATA" }; int[] to = new int[] { R.id.share_account_item_layout }; SimpleAdapter adapter = new SimpleAdapter(activity, data, R.layout.share_extension_account_item, from, to); adapter.setViewBinder(this); setListAdapter(adapter); }
From source file:com.android.test.uibench.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent();//from w w w .j a v a 2 s .c o m String path = intent.getStringExtra(EXTRA_PATH); if (path == null) { path = ""; } else { // not root level, display where we are in the hierarchy setTitle(path); } FragmentManager fm = getSupportFragmentManager(); if (fm.findFragmentById(android.R.id.content) == null) { ListFragment listFragment = new ListFragment() { @Override @SuppressWarnings("unchecked") public void onListItemClick(ListView l, View v, int position, long id) { Map<String, Object> map = (Map<String, Object>) l.getItemAtPosition(position); Intent intent = (Intent) map.get("intent"); startActivity(intent); } @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); getListView().setTextFilterEnabled(true); } }; listFragment.setListAdapter(new SimpleAdapter(this, getData(path), android.R.layout.simple_list_item_1, new String[] { "title" }, new int[] { android.R.id.text1 })); fm.beginTransaction().add(android.R.id.content, listFragment).commit(); } }
From source file:cn.devit.app.ip_messenger.MessageHistorykFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null) { mParam1 = getArguments().getString(ARG_PARAM1); mParam2 = getArguments().getString(ARG_PARAM2); }/*from ww w . j a v a 2 s. co m*/ // TODO: Change Adapter to display your content // setListAdapter(new // ArrayAdapter<DummyContent1.DummyItem>(getActivity(), // android.R.layout.two_line_list_item, new String[] {} // android.R.id.text1, // DummyContent1.ITEMS)); setListAdapter(new SimpleAdapter(getActivity(), DummyContent1.ITEMS, R.layout.message_list_view, new String[] { "text1", "text2", "timestamp" }, new int[] { R.id.text1, R.id.text2, R.id.text_date })); }
From source file:timer.com.maydaysdk.MayDayMessageListFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mContactList = new ArrayList<>(); String[] from = { MayDayConstant.USERNAME, MayDayConstant.MESSAGE_TEXT }; int[] to = { R.id.message_username, R.id.message_text }; mListViewAdapter = new SimpleAdapter(getActivity().getApplicationContext(), mContactList, R.layout.message_row_layout, from, to); setListAdapter(mListViewAdapter);/*ww w . j av a 2 s.co m*/ }
From source file:com.google.sample.oboe.hellooboe.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mAudioApiSpinner = findViewById(R.id.audioApiSpinner); mAudioApiSpinner//w w w . ja v a 2 s .co m .setAdapter(new SimpleAdapter(this, createAudioApisOptionsList(), R.layout.audio_apis_spinner, // the xml layout new String[] { getString(R.string.audio_api_description_key) }, // field to display new int[] { R.id.audioApiOption } // View to show field in )); mAudioApiSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { PlaybackEngine.setAudioApi(i); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); mPlaybackDeviceSpinner = findViewById(R.id.playbackDevicesSpinner); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { mPlaybackDeviceSpinner.setDirectionType(AudioManager.GET_DEVICES_OUTPUTS); mPlaybackDeviceSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { PlaybackEngine.setAudioDeviceId(getPlaybackDeviceId()); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); } mBufferSizeSpinner = findViewById(R.id.bufferSizeSpinner); mBufferSizeSpinner.setAdapter(new SimpleAdapter(this, createBufferSizeOptionsList(), // list of buffer size options R.layout.buffer_sizes_spinner, // the xml layout new String[] { getString(R.string.buffer_size_description_key) }, // field to display new int[] { R.id.bufferSizeOption } // View to show field in )); mBufferSizeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { PlaybackEngine.setBufferSizeInBursts(getBufferSizeInBursts()); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); // initialize native audio system PlaybackEngine.create(); // Periodically update the UI with the output stream latency mLatencyText = findViewById(R.id.latencyText); setupLatencyUpdater(); }
From source file:com.dsi.ant.antplus.pluginsampler.geocache.Activity_GeoScanList.java
@Override 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//from w w w . j a v a2 s . com public void onItemClick(AdapterView<?> parent, View view, int pos, long id) { if (geoPcc == null) return; if (!bDevicesInList) return; int deviceID = Integer.parseInt(deviceList_Display.get(pos).get("desc")); final Dialog_ProgressWaiter progressDialog = new Dialog_ProgressWaiter("Downloading device data"); boolean reqSubmitted = geoPcc.requestDeviceData(deviceID, true, //Display the results if successful or report failures to user new IDataDownloadFinishedReceiver() { @Override public void onNewDataDownloadFinished(GeocacheRequestStatus status, GeocacheDeviceData downloadedData) { StringBuilder error = new StringBuilder("Error Downloading Data: "); switch (status) { case SUCCESS: final Dialog_GeoDeviceDetails detailsDialog = new Dialog_GeoDeviceDetails( geoPcc, downloadedData); runOnUiThread(new Runnable() { @Override public void run() { progressDialog.dismiss(); detailsDialog.show(getSupportFragmentManager(), "DeviceDetails"); } }); return; case FAIL_DEVICE_NOT_IN_LIST: error.append("Device no longer in list"); break; case FAIL_ALREADY_BUSY_EXTERNAL: error.append("Device is busy"); break; case FAIL_DEVICE_COMMUNICATION_FAILURE: error.append("Communication with device failed"); break; case UNRECOGNIZED: runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(Activity_GeoScanList.this, "Failed: UNRECOGNIZED. PluginLib Upgrade Required?", Toast.LENGTH_SHORT).show(); } }); break; default: break; } final String errorStr = error.toString(); runOnUiThread(new Runnable() { @Override public void run() { progressDialog.dismiss(); Toast.makeText(Activity_GeoScanList.this, errorStr, Toast.LENGTH_LONG) .show(); } }); } }, progressDialog.getUpdateReceiver()); if (reqSubmitted) progressDialog.show(getSupportFragmentManager(), "DownloadProgressDialog"); else Toast.makeText(Activity_GeoScanList.this, "Error Downloading Data: PCC already busy or dead", Toast.LENGTH_SHORT).show(); } }); resetPcc(); }
From source file:com.github.volley_examples.Act_JsonRequest.java
private void init() { SimpleAdapter simpleAdapter = new SimpleAdapter(this, list, android.R.layout.simple_list_item_2, new String[] { "title", "content" }, new int[] { android.R.id.text1, android.R.id.text2 }); lvWeather.setAdapter(simpleAdapter); }
From source file:net.phamngochai.beefnoodle.ui.DownloadDictionaryActivity.java
public void downloadAndShowDictionaryList(View view) { String xml = getDictionaryListFromInternet(); if (xml == null) { showAlertDialog("Cannot load the list from internet"); return;//from ww w.jav a 2 s. com } Document doc = stringToXMLDoc(xml); if (doc == null) { showAlertDialog("Cannot parse the list"); return; } for (int i = 0; i < myList.size(); i++) myList.remove(i); NodeList nodes = doc.getElementsByTagName("dictionary"); //fill in the list items from the XML document for (int i = 0; i < nodes.getLength(); i++) { HashMap<String, String> map = new HashMap<String, String>(); Element e = (Element) nodes.item(i); map.put("Name", e.getElementsByTagName("name").item(0).getTextContent()); Log.d(TAG, "Name: " + e.getElementsByTagName("name").item(0).getTextContent()); map.put("Description", e.getElementsByTagName("description").item(0).getTextContent()); Log.d(TAG, "Description: " + e.getElementsByTagName("description").item(0).getTextContent()); map.put("License", e.getElementsByTagName("license").item(0).getTextContent()); Log.d(TAG, "License: " + e.getElementsByTagName("license").item(0).getTextContent()); myList.add(map); } //Make a new listadapter ListAdapter adapter = new SimpleAdapter(this, myList, R.layout.dictionarylistrow, new String[] { "Name", "Description", "License" }, new int[] { R.id.dictionary_name, R.id.dictionary_description, R.id.dictionary_license }); setListAdapter(adapter); }