@Override public void setEntries(CharSequence[] entries) { super.setEntries(entries); if (mDialog != null) { ArrayList<HashMap<String, CharSequence>> listItems = new ArrayList<>(); for (CharSequence entry : entries) { HashMap<String, CharSequence> map = new HashMap<>(); map.put("item", entry); listItems.add(map); } mDialog.getListView().setAdapter(new SimpleAdapter( mContext, listItems, R.layout.select_dialog_singlechoice_material, new String[] {"item"}, new int[]{android.R.id.text1} )); } }
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_exchange_rmb_quotation); StatusBarUtil.setColor(this, getResources().getColor(R.color.colorPrimary)); btnICBC = forceCast(findViewById(R.id.btnICBC)); btnCMB = forceCast(findViewById(R.id.btnCMB)); btnCCB = forceCast(findViewById(R.id.btnCCB)); btnBOC = forceCast(findViewById(R.id.btnBOC)); btnBCM = forceCast(findViewById(R.id.btnBCM)); btnABC = forceCast(findViewById(R.id.btnABC)); tvTittle = forceCast(findViewById(R.id.tvTittle)); lvResult = forceCast(findViewById(R.id.lvResult)); btnICBC.setOnClickListener(this); btnCMB.setOnClickListener(this); btnCCB.setOnClickListener(this); btnBOC.setOnClickListener(this); btnBCM.setOnClickListener(this); btnABC.setOnClickListener(this); //init data adapter = new SimpleAdapter(this, dataList, R.layout.view_exchange_rmb_quotation_item, new String[]{"bankName", "bank", "currencyName", "currencyCode", "fBuyPri", "mBuyPri", "fSellPri", "mSellPri", "bankConversionPri", "date", "time"}, new int[]{R.id.tvBankName, R.id.tvBankCode, R.id.tvCurrencyName, R.id.tvCurrencyCode, R.id.tvFBuyPri, R.id.tvMBuyPri, R.id.tvFSellPri, R.id.tvMSellPri, R.id.tvBankConversionPri, R.id.tvDate, R.id.tvTime}); lvResult.setAdapter(adapter); }
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_lottery); StatusBarUtil.setColor(this, getResources().getColor(R.color.colorPrimary)); etPeriod = forceCast(findViewById(R.id.etPeriod)); tvDateTime = forceCast(findViewById(R.id.tvDateTime)); tvName = forceCast(findViewById(R.id.tvName)); tvSales = forceCast(findViewById(R.id.tvSales)); tvPool = forceCast(findViewById(R.id.tvPool)); tvPeriod = forceCast(findViewById(R.id.tvPeriod)); tvLotteryNumber = forceCast(findViewById(R.id.tvLotteryNumber)); GridView gvLotteryList = forceCast(findViewById(R.id.gvLotteryList)); ListView lvLotteryResult = forceCast(findViewById(R.id.lvLotteryAward)); gvLotteryList.setOnItemClickListener(this); //init data updateLotteryInfo(null, null, null, null, null, null); lotteryTypeList = new ArrayList<HashMap<String, Object>>(); lotteryTypeListAdapter = new SimpleAdapter(this, lotteryTypeList, android.R.layout.simple_list_item_1, new String[]{"name"}, new int[]{android.R.id.text1}); gvLotteryList.setAdapter(lotteryTypeListAdapter); lotteryResultList = new ArrayList<HashMap<String, Object>>(); lotteryResultAdapter = new LotteryResultAdapter(this, lotteryResultList); lvLotteryResult.setAdapter(lotteryResultAdapter); //获取彩种列表 ((Lottery) forceCast(MobAPI.getAPI(Lottery.NAME))).queryLotteryList(LotteryAPIActivity.this); }
private void init() { ListView search_list = (ListView) findViewById(R.id.search_list); SimpleAdapter adapter = new SimpleAdapter(this, getLocationList(), R.layout.item_location_favorites, new String[]{"name", "detail", "item_type"}, new int[]{R.id.location_name, R.id.location_detail, R.id.item_type_icon}); search_list.setAdapter(adapter); /* search_box = (EditText) findViewById(R.id.search_box); search_box.addTextChangedListener(this); clear_progress_btn = (ImageView) findViewById(R.id.clear_progress_icon); clear_progress_btn.setOnClickListener(this); clear_progress_btn.setImageDrawable(null); mPlaceAPI = new PlaceOpenAPI(this, WeiboData.APP_KEY, WeiboData.readAccessToken(this)); */ }
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(android.R.layout.list_content); List<Map<String, String>> list = new ArrayList<Map<String, String>>(); HashMap<String, String> ntext = new HashMap<String, String>(); ntext.put("name", "this.name = (data.time > data.id) && (data.time >= 3)"); list.add(ntext); HashMap<String, String> page = new HashMap<String, String>(); page.put("name", "PageScrollScript"); page.put("class", ComponentActivity.class.getName()); page.put("data", "component_demo/page_item.json"); list.add(page); HashMap<String, String> click = new HashMap<String, String>(); click.put("name", "ClickScript"); click.put("class", ComponentActivity.class.getName()); list.add(click); ListAdapter listAdapter = new SimpleAdapter(this, list, android.R.layout.simple_list_item_1, new String[]{"name"}, new int[]{android.R.id.text1}); setListAdapter(listAdapter); }
/** * 设置第一列数据 */ private SimpleAdapter getSimpleAdapter_1() { listData = new ArrayList<Map<String, String>>(); Map<String, String> map = new HashMap<String, String>(); map.put("text", "账户设置"); listData.add(map); map = new HashMap<String, String>(); map.put("text", "个人资料"); listData.add(map); return new SimpleAdapter(mContext, listData, R.layout.setting_list_item, new String[] { "text" }, new int[] { R.id.tv_list_item }); }
/** * 设置第二列数据 */ private SimpleAdapter getSimpleAdapter_2() { listData2 = new ArrayList<Map<String, String>>(); Map<String, String> map = new HashMap<String, String>(); map.put("text", "屏蔽发现"); listData2.add(map); map = new HashMap<String, String>(); map.put("text", "会员介绍"); listData2.add(map); map = new HashMap<String, String>(); map.put("text", "意见反馈"); listData2.add(map); map = new HashMap<String, String>(); map.put("text", "小嗨帮助"); listData2.add(map); return new SimpleAdapter(mContext, listData2, R.layout.setting_list_item, new String[] { "text" }, new int[] { R.id.tv_list_item }); }
/** * 设置第一列数据 */ private SimpleAdapter getSimpleAdapter_1() { listData = new ArrayList<Map<String, String>>(); mProvinceArr = this.getResources().getStringArray(R.array.province); for(int i = 0;i < mProvinceArr.length;i++) { Map<String, String> map = new HashMap<String, String>(); map.put("text", mProvinceArr[i]); listData.add(map); } // Map<String, String> map = new HashMap<String, String>(); // map.put("text", "账户设置"); // listData.add(map); // // map = new HashMap<String, String>(); // map.put("text", "个人资料"); // listData.add(map); return new SimpleAdapter(EditProvinceActivity.this, listData, R.layout.province_list_item, new String[] { "text" }, new int[] { R.id.tv_province_list_item }); }
/** * 设置第一列数据 */ private SimpleAdapter getSimpleAdapter_1() { listData = new ArrayList<Map<String, String>>(); mProvinceArr = this.getResources().getStringArray(R.array.province); for(int i = 0;i < mProvinceArr.length;i++) { Map<String, String> map = new HashMap<String, String>(); map.put("text", mProvinceArr[i]); listData.add(map); } // Map<String, String> map = new HashMap<String, String>(); // map.put("text", "账户设置"); // listData.add(map); // // map = new HashMap<String, String>(); // map.put("text", "个人资料"); // listData.add(map); return new SimpleAdapter(RegProvinceActivity.this, listData, R.layout.province_list_item, new String[] { "text" }, new int[] { R.id.tv_province_list_item }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // One-time singleton initialization; requires activity context to get file location. ContentManager.initialize(this); setListAdapter(new SimpleAdapter(this, createActivityList(), android.R.layout.two_line_list_item, new String[] { TITLE, DESCRIPTION }, new int[] { android.R.id.text1, android.R.id.text2 } )); ContentManager cm = ContentManager.getInstance(); if (!cm.isContentCreated(this)) { ContentManager.getInstance().createAll(this); } ActivityCompat.requestPermissions(this, PERMISSIONS, 1); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); String path = intent.getStringExtra(APP_PATH); if (path == null) { path = ""; } setListAdapter(new SimpleAdapter(this, getData(path), android.R.layout.simple_list_item_1, new String[] { "title" }, new int[] { android.R.id.text1 })); getListView().setTextFilterEnabled(true); // String testStr = "<sss > <sss> <贷款及覅> dfsh <a > ksdjfk </a>"; // HtmlFormater.stripHtmlTagByJsoup(testStr); // NumberFormat nf = NumberFormat.getPercentInstance(); // try { // nf.parse("0"); // } catch (ParseException e) { // e.printStackTrace(); // } }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_buy_ticket_info, null); lvInfos = (ListView) v.findViewById(R.id.buyTicketInfo_lvInfos); MyDatabase myDB = new MyDatabase(this.getActivity()); mAdapter= new SimpleAdapter(this.getActivity(), mLstDatas, R.layout.item_buy_ticket_info, new String[]{MyDatabase.KEY, MyDatabase.VALUE}, new int[]{R.id.item_buy_ticket_info_tvQuestion, R.id.item_buy_ticket_info_tvAnswer} ); lvInfos.setAdapter(mAdapter); myDB.closeDB(); notifyAdapterDataChanged(myDB.getTicketInfos(0)); MyUtils.setListViewHeightBasedOnChildren(lvInfos); //设置ListView全部显示 ViewGroup.LayoutParams params = lvInfos.getLayoutParams(); params.height += 3000; //方法不太准,人为校正高度 lvInfos.setLayoutParams(params); sv1 = (ScrollView)v.findViewById(R.id.buyTicketInfo_sv1); sv1.smoothScrollTo(0, 20); return v; }
private void initViews() { GridView gvIcons = (GridView) findViewById(R.id.icons); SimpleAdapter adapter = new SimpleAdapter(this, getIcons(), R.layout.item_editimage, new String[] { "item", "resId" }, new int[] { R.id.item_editimage_ivIcon, R.id.item_editimaeg_tvResId }); gvIcons.setAdapter(adapter); gvIcons.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { TextView tv1 = (TextView) arg1 .findViewById(R.id.item_editimaeg_tvResId); int resId = Integer.valueOf(tv1.getText().toString()); Intent intent = new Intent(); intent.putExtra(RESULT, resId); EditImageAty.this.setResult(EditImageAty.this.getIntent() .getIntExtra(C_RESULT_CODE, 0), intent); EditImageAty.this.finish(); } }); }
public void intint(){ db.open(); Cursor c = db.getAllContacts(); if (c.moveToFirst()) { do { id = c.getString(c.getColumnIndex("_id")); name = c.getString(c.getColumnIndex("name")); number = c.getString(c.getColumnIndex("phonenum")); Map<String, Object> map = new HashMap<String, Object>(); map.put("contacts_name", name); map.put("contacts_num", number); dataList.add(map); simpleadapter = new SimpleAdapter(this, dataList, R.layout.contact_text, new String[]{"contacts_name","contacts_num"}, new int[]{R.id.contacts_name,R.id.contacts_num}); listView.setAdapter(simpleadapter); // DisplayContact(c); }while (c.moveToNext()); db.close(); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Loggers.DEBUG = true; CrashHandler.init(getApplicationContext()); getPermission(); Intent intent = getIntent(); String path = intent.getStringExtra(INTENT_PATH); if (path == null) { path = ""; } /*** The "title" is the "key" in "Map" ***/ setListAdapter(new SimpleAdapter(this, getData(path), android.R.layout.simple_list_item_1, new String[] { "title" }, new int[] { android.R.id.text1 })); //If you can get the keyboard, you can type to search the items of the list getListView().setTextFilterEnabled(true); }
private void refreshApps() { // (re)load the list of apps in the background final PackageManager pm = getPackageManager(); List<PackageInfo> pkgs = getPackageManager().getInstalledPackages(0); List<Map<String,Object>> returnBackList = new ArrayList<Map<String, Object>>(); for(PackageInfo i:pkgs){ if((i.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) > 0 ) continue; //跳过系统应用 Map<String, Object> map = new HashMap<String, Object>(); map.put("title", String.valueOf(i.applicationInfo.loadLabel(pm))); map.put("info", String.valueOf(i.applicationInfo.packageName)); map.put("img", i.applicationInfo.loadIcon(pm)); returnBackList.add(map); } SimpleAdapter adapter = new SimpleAdapter(this,returnBackList,R.layout.vlist, new String[]{"title","info","img"}, new int[]{R.id.title,R.id.info,R.id.img}); list.setAdapter(adapter); }
private void updateListView(File filesDir) { setTitle(filesDir.getName()); filePath = filesDir.getAbsolutePath(); fileHandler.post(() -> { List<HashMap<String, Object>> files = loadFiles(filesDir); listView.setAdapter(new SimpleAdapter( this, files, android.R.layout.simple_list_item_1, new String[]{"name"}, new int[]{android.R.id.text1} )); listView.setOnItemClickListener((parent, view, position, id) -> { File clickedFile = (File) files.get(position).get("file"); if (clickedFile.isFile()) { handleFileClick(clickedFile); } else if (clickedFile.isDirectory()) { updateListView(clickedFile); } }); }); }
@Override protected void onPostExecute(Void result) { super.onPostExecute(result); // Dismiss the progress dialog if (pDialog.isShowing()) pDialog.dismiss(); // Sorting a-z Collections.sort(posList, new Comparator<HashMap< String,String >>() { @Override public int compare(HashMap<String, String> lhs, HashMap<String, String> rhs) { return lhs.get("name").compareTo(rhs.get("name")); } }); // Updating parsed JSON data into ListView ListAdapter adapter = new SimpleAdapter( PropinsiActivity.this, posList, R.layout.list_daerah, new String[]{"name"}, new int[]{R.id.name}); lv.setAdapter(adapter); }
@Override protected void onPostExecute(Void result) { super.onPostExecute(result); // Dismiss the progress dialog if (pDialog.isShowing()) pDialog.dismiss(); // Sorting a-z Collections.sort(posList, new Comparator<HashMap< String,String >>() { @Override public int compare(HashMap<String, String> lhs, HashMap<String, String> rhs) { return lhs.get("kecamatan").compareTo(rhs.get("kecamatan")); } }); // Updating parsed JSON data into ListView ListAdapter adapter = new SimpleAdapter( KotaActivity.this, posList, R.layout.list_pos, new String[]{"kecamatan", "kelurahan", "kodepos"}, new int[]{R.id.kecamatan, R.id.kelurahan, R.id.kodepos}); lv.setAdapter(adapter); }
@Override protected void onPostExecute(Void result) { super.onPostExecute(result); // Dismiss the progress dialog if (pDialog.isShowing()) pDialog.dismiss(); // Sorting a-z Collections.sort(posList, new Comparator<HashMap< String,String >>() { @Override public int compare(HashMap<String, String> lhs, HashMap<String, String> rhs) { return lhs.get("name").compareTo(rhs.get("name")); } }); // Updating parsed JSON data into ListView ListAdapter adapter = new SimpleAdapter( MainActivity.this, posList, R.layout.list_daerah, new String[]{"name"}, new int[]{R.id.name}); lv.setAdapter(adapter); }
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); this.setContentView(R.layout.label_dialog); labelList = (ListView) findViewById(R.id.label_list); cancel = (Button) findViewById(R.id.cancel); // ListView SimpleAdapter adapter = new SimpleAdapter(context, getLabelList(), R.layout.label_list_item, new String[]{"label_img", "label_value"}, new int[]{ R.id.label_img, R.id.label_value}); labelList.setAdapter(adapter); //ListView labelList .setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) { HashMap<String, Object> label = getLabelList().get(position); selectedLabel = (String) label.get("label_value"); ToodooOptionsModel ToodooOptionsModel = toodooOptionsList.get(0); ToodooOptionsModel.setOptionValue(selectedLabel); mAdapter.notifyDataSetChanged(); labelDialog.dismiss(); } }); cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { labelDialog.dismiss(); } }); }
public SimpleAdapter getAdapter(Context context, String nutrient) { ArrayList<HashMap<String, Object>> listItem = new ArrayList<HashMap<String, Object>>(); String[] s = nutrient.split(";"); for (int i = 0; i < s.length; i++) { HashMap<String, Object> map = new HashMap<String, Object>(); String[] s1 = s[i].split(":"); if (s1.length == 1) // ��ֹ����ĸ�ʽ��û��":"����split�����ַ������� return null; String name = s1[0]; String content = s1[1]; String comment = "";// Integer.parseInt(s1[1]); map.put("nutrient_name", name); map.put("nutrient_content", content); map.put("nutrient_comment", comment); listItem.add(map); } SimpleAdapter mSimpleAdapter = new SimpleAdapter(context, listItem, R.layout.food_nutrient_list_item, new String[] { "nutrient_name", "nutrient_content", "nutrient_comment" }, new int[] { R.id.nutrient_name, R.id.nutrient_content, R.id.nutrient_comment }); return mSimpleAdapter; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); String path = intent.getStringExtra("com.example.ku.collection.Path"); if (path == null) { path = ""; } setListAdapter(new SimpleAdapter(this, getData(path), android.R.layout.simple_list_item_1, new String[] { "title" }, new int[] { android.R.id.text1 })); getListView().setTextFilterEnabled(true); mHandler.sendEmptyMessageDelayed(1,200); mHandler.removeMessages(1); }
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ArrayList<Map<String, Object>> list = new ArrayList<>(DATA.length); for (Class clz : DATA) { Map<String, Object> map = new HashMap<>(1); map.put("Title", clz.getSimpleName()); map.put("Class", clz); list.add(map); } ListView listView = new ListView(this); listView.setAdapter(new SimpleAdapter(this, list, android.R.layout.simple_list_item_1, new String[]{"Title"}, new int[]{android.R.id.text1})); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override @SuppressWarnings("unchecked") public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { Map<String, Object> data = (Map<String, Object>)adapterView.getItemAtPosition(i); startActivity(new Intent(LauncherActivity.this, (Class)data.get("Class"))); } }); setContentView(listView); }
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); // layout setContentView(R.layout.activity_services); // toolbar final Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); // set up the action bar final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayOptions(ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP); } // adapter final SimpleAdapter adapter = Services.makeAdapter(this, R.layout.item_services, from, to, true); final ListView listView = findViewById(R.id.services); listView.setAdapter(adapter); }
public void showHistoryList() { for (String str : historyArr) { if (str != null) { Map<String, String> map = new HashMap<>(); map.put("textViewIp", str); historyList.add(map); } } simpleAdapter = new SimpleAdapter(getContext(), historyList, android.R.layout.simple_dropdown_item_1line, new String[]{"textViewIp"}, new int[]{android.R.id.text1}); listView.setAdapter(simpleAdapter); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); listView = (ListView) findViewById(R.id.lv_list); //设置适配器 //SimpleAdapter的参数说明 // 第一个参数 表示访问整个android应用程序接口,基本上所有的组件都需要 // 第二个参数表示生成一个Map(String ,Object)列表选项 // 第三个参数表示界面布局的id 表示该文件作为列表项的组件 // 第四个参数表示该Map对象的哪些key对应value来生成列表项 // 第五个参数表示来填充的组件 Map对象key对应的资源一依次填充组件 顺序有对应关系 listView.setAdapter(new SimpleAdapter(this, readContact(), R.layout.contact_list_item, new String[]{"name", "phone"}, new int[]{R.id.tv_name, R.id.tv_phone})); }
private void setCategoryListView() { String[] from = { DatabaseContract.Category._ID, DatabaseContract.Category.KEY_NAME }; int[] to = { R.id.id_category_textview, R.id.name_category_textview }; SimpleAdapter arrayAdapter = new SimpleAdapter( this, categories, R.layout.choose_category_list_item, from, to ); // DataBind ListView with items from ArrayAdapter categoryListView.setAdapter(arrayAdapter); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addItem("[ Launch SampleActivity ]", null); addItem("[ Default.apk ]", null); try { AssetManager asset = getAssets(); for (String s : asset.list("apks")) { addItem(s, "apks/" + s); } } catch (Exception e) { } SimpleAdapter adapter = new SimpleAdapter(this, data, android.R.layout.simple_list_item_1, new String[] { "title" }, new int[] { android.R.id.text1 }); setListAdapter(adapter); }
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); try { AssetManager asset = getActivity().getAssets(); for (String s : asset.list("apks")) { addItem(s, "apks/" + s); } } catch (Exception e) { } SimpleAdapter adapter = new SimpleAdapter(getActivity(), data, android.R.layout.simple_list_item_1, new String[] { "title" }, new int[] { android.R.id.text1 }); setListAdapter(adapter); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); CrashHandler.init(getApplicationContext()); Loggers.DEBUG = true; getPermission(); Intent intent = getIntent(); String path = intent.getStringExtra(INTENT_PATH); if (path == null) { path = ""; } /*** The "title" is the "key" in "Map" ***/ setListAdapter(new SimpleAdapter(this, getData(path), android.R.layout.simple_list_item_1, new String[] { "title" }, new int[] { android.R.id.text1 })); //If you can get the keyboard, you can type to search the items of the list getListView().setTextFilterEnabled(true); }
@Override public void onNearbyPeers(List<NearbyUser> nearbyPeers) { List<Map<String, String>> list = new ArrayList<>(); for (NearbyUser nearbyUser : nearbyPeers) { if (nearbyUser.username != null) { HashMap<String, String> map = new HashMap<>(); map.put("username", nearbyUser.username); map.put("crocoId", nearbyUser.crocoId); list.add(map); } } String[] from = { "username", "crocoId" }; int[] to = { android.R.id.text1, android.R.id.text2 }; SimpleAdapter adapter = new SimpleAdapter(getContext(), list, android.R.layout.simple_list_item_2, from, to); // this is a terrible way how to update items setListAdapter(adapter); }
@Override void refreshData(IEntityRecord entityRecord) { if (entityRecord == null) { return; } //Popula os campos adicionais. List<Map<String, CharSequence>> data = new ArrayList<>(); for (IDetailFieldMapping fieldMapping : fieldsMappings) { String label = fieldMapping.getLabel(); //Formata o valor utilizandos a máscara definida para o campo, de acordo com o seu tipo. CharSequence value = attributesFormatter.formatAttributeValueToText(entityRecord, fieldMapping.getAttribute()); Map<String, CharSequence> dataItem = new HashMap<>(); dataItem.put(DetailFieldAdapter.LABEL_COLUMN, label); dataItem.put(DetailFieldAdapter.VALUE_COLUMN, value); data.add(dataItem); } SimpleAdapter adapter = new DetailFieldAdapter(context, data, fieldsMappings); fieldsList.setAdapter(adapter); }
@Override public boolean onPreferenceClick(final Preference preference) { final Builder b = new Builder(ctx); final int l = NOTIFICAION_STR.length; final String[] cols = new String[]{"icon", "text"}; final ArrayList<HashMap<String, Object>> rows = new ArrayList<>(); for (int i = 0; i < l; i++) { final HashMap<String, Object> m = new HashMap<>(2); m.put(cols[0], NOTIFICAION_IMG[i]); m.put(cols[1], ctx.getString(NOTIFICAION_STR[i])); rows.add(m); } b.setAdapter(new SimpleAdapter(ctx, rows, R.layout.notification_icons_item, cols, new int[]{android.R.id.icon, android.R.id.text1}), new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { preference.getEditor().putInt(preference.getKey(), which).commit(); } }); b.setNegativeButton(android.R.string.cancel, null); b.show(); return true; }
@Override public boolean onPreferenceClick(final Preference preference) { final Builder b = new Builder(ctx); final int l = BUBBLES_STR.length; final String[] cols = new String[]{"icon", "text"}; final ArrayList<HashMap<String, Object>> rows = new ArrayList<>(); for (int i = 0; i < l; i++) { final HashMap<String, Object> m = new HashMap<>(2); m.put(cols[0], BUBBLES_IMG[i]); m.put(cols[1], ctx.getString(BUBBLES_STR[i])); rows.add(m); } b.setAdapter(new SimpleAdapter(ctx, rows, R.layout.bubbles_item, cols, new int[]{ android.R.id.icon, android.R.id.text1}), new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { preference.getEditor().putInt(preference.getKey(), which).commit(); } }); b.setNegativeButton(android.R.string.cancel, null); b.show(); return true; }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ListView listView = new ListView(this); setContentView(listView); Log.d(TAG, TAG + " task id: " + getTaskId()); Intent intent = getIntent(); String path = intent.getStringExtra(getPackageName() + ".Path"); if (path == null) { path = ""; } listView.setAdapter(new SimpleAdapter(this, getData(path), android.R.layout.simple_list_item_1, new String[]{"title"}, new int[]{android.R.id.text1})); listView.setTextFilterEnabled(true); listView.setOnItemClickListener(this); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_info); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_info); setSupportActionBar(toolbar); getSupportActionBar().setTitle(getString(R.string.title_titlebar_info)); getSupportActionBar().setDisplayHomeAsUpEnabled(true); initList(); ListView lv = (ListView) findViewById(R.id.list_info); SimpleAdapter simpleAdpt = new SimpleAdapter(this, infoList, android.R.layout.simple_list_item_1, new String[] {"info"}, new int[] {android.R.id.text1}); lv.setAdapter(simpleAdpt); lv.setOnItemClickListener(this); lv.setSelection(0); //views TextView tvVersionName=(TextView)findViewById(R.id.label_version); tvVersionName.setText("v"+BuildConfig.VERSION_NAME); }
void FillLists() { // We use a - sign to tell that this text should be stiked through SimpleAdapter.ViewBinder vb = new SimpleAdapter.ViewBinder() { public boolean setViewValue(View view, Object data, String textRepresentation) { TextView tv = (TextView) view; tv.setText(textRepresentation.substring(1)); if (textRepresentation.substring(0, 1).equals("-")) { tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); } return true; } }; ArrayList<HashMap<String, String>> feedList; feedList = createAlertsMap(false); SimpleAdapter simpleAdapterLow = new SimpleAdapter(this, feedList, R.layout.row_alerts, new String[]{"alertName", "alertThreshold", "alertTime", "alertMp3File", "alertOverrideSilenceMode"}, new int[]{R.id.alertName, R.id.alertThreshold, R.id.alertTime, R.id.alertMp3File, R.id.alertOverrideSilent}); simpleAdapterLow.setViewBinder(vb); listViewLow.setAdapter(simpleAdapterLow); feedList = createAlertsMap(true); SimpleAdapter simpleAdapterHigh = new SimpleAdapter(this, feedList, R.layout.row_alerts, new String[]{"alertName", "alertThreshold", "alertTime", "alertMp3File", "alertOverrideSilenceMode"}, new int[]{R.id.alertName, R.id.alertThreshold, R.id.alertTime, R.id.alertMp3File, R.id.alertOverrideSilent}); simpleAdapterHigh.setViewBinder(vb); listViewHigh.setAdapter(simpleAdapterHigh); }