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:subhamguptaminor.androidbelieve.drawerwithswipetabs.CardFlipActivity.java
protected void showList2() { try {/*from w w w . ja v a 2 s.c om*/ JSONObject jsonObj1 = new JSONObject(myJSON1); peoples1 = jsonObj1.getJSONArray(TAG_RESULTS1); for (int i = 0; i < peoples1.length(); i++) { JSONObject c = peoples1.getJSONObject(i); String ans = c.getString(TAG_ANS); HashMap<String, String> persons1 = new HashMap<String, String>(); persons1.put(TAG_ANS, ans); personList1.add(persons1); } ListAdapter adapter1 = new SimpleAdapter(CardFlipActivity.this, personList1, R.layout.list_ans, new String[] { TAG_ANS }, new int[] { R.id.answer }); list1.setAdapter(adapter1); //Toast.makeText(, "Updating", Toast.LENGTH_SHORT).show(); } catch (JSONException e) { e.printStackTrace(); } }
From source file:net.olejon.mdapp.Icd10ChapterActivity.java
private void populateListView(String searchString) { final ArrayList<HashMap<String, String>> itemsArrayList = new ArrayList<>(); mCodesArrayList = new ArrayList<>(); mNamesArrayList = new ArrayList<>(); String[] fromColumns = new String[] { "code", "name" }; int[] toViews = new int[] { R.id.icd10_chapter_list_item_code, R.id.icd10_chapter_list_item_name }; try {//from w ww.j ava 2 s . c om for (int i = 0; i < mData.length(); i++) { HashMap<String, String> item = new HashMap<>(); JSONObject itemJsonObject = mData.getJSONObject(i); String code = itemJsonObject.getString("code"); String name = itemJsonObject.getString("name"); if (searchString == null) { item.put("code", code); item.put("name", name); itemsArrayList.add(item); mCodesArrayList.add(code); mNamesArrayList.add(name); } else if (code.matches("(?i).*?" + searchString + ".*") || name.matches("(?i).*?" + searchString + ".*")) { item.put("code", code); item.put("name", name); itemsArrayList.add(item); mCodesArrayList.add(code); mNamesArrayList.add(name); } } } catch (Exception e) { Log.e("Icd10ChapterActivity", Log.getStackTraceString(e)); } SimpleAdapter simpleAdapter = new SimpleAdapter(mContext, itemsArrayList, R.layout.activity_icd10_chapter_list_item, fromColumns, toViews); mListView.setAdapter(simpleAdapter); }
From source file:com.abc.driver.TruckActivity.java
public void chooseTruckWeight(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(this); GridView gridView1 = new GridView(this); gridView1.setNumColumns(3);/*from w w w.j av a 2 s . c om*/ SimpleAdapter adapter = new SimpleAdapter(this, mTruckWeightList, R.layout.truck_weight_griditem, new String[] { "TITLE", "TWEIGHT" }, new int[] { R.id.griditem_title, R.id.griditem_weight, }); gridView1.setAdapter(adapter); builder.setTitle("Please Choose"); builder.setInverseBackgroundForced(true); builder.setView(gridView1); final Dialog dialog = builder.create(); gridView1.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long rowId) { mTWtv.setText(((TextView) view.findViewById(R.id.griditem_title)).getText()); mTruckWeight = ((TextView) view.findViewById(R.id.griditem_weight)).getText().toString(); mUpdateTruckTask = new UpdateTruckTask(); mUpdateTruckTask.execute("" + app.getUser().getMyTruck().getTruckId(), "" + app.getUser().getMyTruck().getTypeId(), "" + app.getUser().getMyTruck().getLengthId(), mTruckWeight, "" + app.getUser().getMyTruck().getStatusId(), "" + app.getUser().getId()); dialog.dismiss(); } }); dialog.show(); }
From source file:se.anyro.tagtider.StationActivity.java
private void addAdapter() { sTransfersAdapter = new SimpleAdapter(this, sTransfers, R.layout.transfer_row, mFrom, TO); sTransfersAdapter.setViewBinder(viewBinder); setListAdapter(sTransfersAdapter);//from w w w .j av a 2 s. c om }
From source file:com.jefftharris.passwdsafe.FileListFragment.java
/** Update files after the loader is complete */ private void updateFiles(List<Map<String, Object>> fileData) { SimpleAdapter adapter = null;/* www.ja va 2s.c o m*/ if (fileData != null) { adapter = new SimpleAdapter(getActivity(), fileData, R.layout.file_list_item, new String[] { TITLE, ICON, MOD_DATE }, new int[] { R.id.text, R.id.icon, R.id.mod_date }); adapter.setViewBinder(new SimpleAdapter.ViewBinder() { @Override public boolean setViewValue(View view, Object data, String textRepresentation) { switch (view.getId()) { case R.id.text: { TextView tv = (TextView) view; tv.setText(textRepresentation); tv.requestLayout(); return true; } case R.id.mod_date: { if (data == null) { view.setVisibility(View.GONE); return true; } else { view.setVisibility(View.VISIBLE); return false; } } } return false; } }); } View rootView = getView(); if (rootView == null) { // Fragment destroyed return; } View groupPanel = rootView.findViewById(R.id.current_group_panel); TextView groupLabel = (TextView) rootView.findViewById(R.id.current_group_label); TextView emptyLabel = (TextView) rootView.findViewById(android.R.id.empty); if (itsDir == null) { groupPanel.setVisibility(View.GONE); groupLabel.setText(""); emptyLabel.setText(R.string.ext_storage_not_mounted); } else { groupPanel.setVisibility(View.VISIBLE); groupLabel.setText(itsDir.toString()); emptyLabel.setText(R.string.no_files); } setListAdapter(adapter); // Open the default file if (getListAdapter() != null) { Activity act = getActivity(); PasswdSafeApp app = (PasswdSafeApp) act.getApplication(); if (app.checkOpenDefault()) { SharedPreferences prefs = Preferences.getSharedPrefs(act); Uri defFile = Preferences.getDefFilePref(prefs); if (defFile != null) { itsListener.openFile(defFile, null); } } } }
From source file:net.tjado.passwdsafe.FileListFragment.java
/** Update files after the loader is complete */ private void updateFiles(List<Map<String, Object>> fileData) { SimpleAdapter adapter = null;/*w w w. j a v a 2 s . com*/ if (fileData != null) { adapter = new SimpleAdapter(getActivity(), fileData, R.layout.file_list_item, new String[] { TITLE, ICON, MOD_DATE }, new int[] { R.id.text, R.id.icon, R.id.mod_date }); adapter.setViewBinder(new SimpleAdapter.ViewBinder() { @Override public boolean setViewValue(View view, Object data, String textRepresentation) { switch (view.getId()) { case R.id.icon: { ImageView iv = (ImageView) view; iv.setImageResource((int) data); iv.setColorFilter(getResources().getColor(R.color.treeview_icons)); return true; } case R.id.text: { TextView tv = (TextView) view; tv.setText(textRepresentation); tv.requestLayout(); return true; } case R.id.mod_date: { if (data == null) { view.setVisibility(View.GONE); return true; } else { view.setVisibility(View.VISIBLE); return false; } } } return false; } }); } View rootView = getView(); if (rootView == null) { // Fragment destroyed return; } View groupPanel = rootView.findViewById(R.id.current_group_panel); TextView groupLabel = (TextView) rootView.findViewById(R.id.current_group_label); TextView emptyLabel = (TextView) rootView.findViewById(android.R.id.empty); if (itsDir == null) { groupPanel.setVisibility(View.GONE); groupLabel.setText(""); emptyLabel.setText(R.string.ext_storage_not_mounted); } else { groupPanel.setVisibility(View.VISIBLE); groupLabel.setText(itsDir.toString()); emptyLabel.setText(R.string.no_files); } setListAdapter(adapter); // Open the default file if (getListAdapter() != null) { Activity act = getActivity(); PasswdSafeApp app = (PasswdSafeApp) act.getApplication(); if (app.checkOpenDefault()) { SharedPreferences prefs = Preferences.getSharedPrefs(act); Uri defFile = Preferences.getDefFilePref(prefs); if (defFile != null) { itsListener.openFile(defFile, null); } } } }
From source file:com.appdevper.mediaplayer.activity.ActionBarCastActivity.java
private void populateDrawerItems() { mDrawerMenuContents = new DrawerMenuContents(this); final int selectedPosition = mDrawerMenuContents.getPosition(this.getClass()); final int unselectedColor = Color.WHITE; final int selectedColor = getResources().getColor(R.color.drawer_item_selected_background); SimpleAdapter adapter = new SimpleAdapter(this, mDrawerMenuContents.getItems(), R.layout.drawer_list_item, new String[] { DrawerMenuContents.FIELD_TITLE, DrawerMenuContents.FIELD_ICON }, new int[] { R.id.drawer_item_title, R.id.drawer_item_icon }) { @Override//www . j a v a 2 s . c o m public View getView(int position, View convertView, ViewGroup parent) { View view = super.getView(position, convertView, parent); int color = unselectedColor; if (position == selectedPosition) { color = selectedColor; } view.setBackgroundColor(color); return view; } }; mDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (position != selectedPosition) { //view.setBackgroundColor(getResources().getColor(R.color.drawer_item_selected_background)); mItemToOpenWhenDrawerCloses = position; } mDrawerLayout.closeDrawers(); } }); mDrawerList.setAdapter(adapter); }
From source file:ua.com.spacetv.mycookbook.dialogs.FragDialog.java
private void categoryInList() { Cursor cursor = mDatabase.query(TABLE_TOP_CATEGORY, null, null, null, null, null, "category", null); if (cursor != null) { if (cursor.moveToFirst()) { do {/* w w w . j a v a 2 s . co m*/ map = new HashMap<>(); map.put(TITLE_CATEGORY, cursor.getString(1)); map.put(ID_ITEM, cursor.getInt(0)); map.put(TYPE_FOLDER, PARENT); map.put(IMG, R.drawable.ic_folder_black_48dp); data.add(map); subCategoryInList(cursor.getInt(0)); } while (cursor.moveToNext()); } cursor.close(); } String[] from = { TITLE_CATEGORY, TITLE_SUBCATEGORY, IMG, ID_ITEM, TYPE_FOLDER }; int[] to = { R.id.textListDialogTitle, R.id.textListDialogSubTitle, R.id.imgTopCategory }; SimpleAdapter sAdapter = new SimpleAdapter(getActivity(), data, R.layout.format_list_dialog, from, to); listView.setAdapter(sAdapter); }
From source file:com.inde.shiningdays.MainActivity.java
private SimpleAdapter getSimpleAdapter() { List<Map<String, Object>> data = TypeActivity.getDefaultData(this, true); data.addAll(TypeActivity.getCustomData(this, true)); SimpleAdapter adapter = new SimpleAdapter(this, data, R.layout.drawer_list_item, new String[] { "icon", "type" }, new int[] { R.id.type_icon, R.id.type_item }); return adapter; }
From source file:com.opencabinetlabs.destinycommunityhub.ui.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Crashlytics.start(this); getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); if (isFinishing()) { return;/*from w ww .ja v a 2s . c om*/ } setContentView(R.layout.activity_main); bindViews(); // Enabling Up navigation getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setDisplayShowHomeEnabled(true); getActionBar().setIcon(R.drawable.action_bar_icon); if (savedInstanceState != null) { mCommunityNewsFragment = (CommunityNewsFragment) getSupportFragmentManager() .getFragment(savedInstanceState, CommunityNewsFragment.class.getName()); mVideosFragment = (VideosFragment) getSupportFragmentManager().getFragment(savedInstanceState, VideosFragment.class.getName()); mCommunityFragment = (CommunityFragment) getSupportFragmentManager().getFragment(savedInstanceState, CommunityFragment.class.getName()); mTwitterStreamFragment = (TwitterStreamFragment) getSupportFragmentManager() .getFragment(savedInstanceState, TwitterStreamFragment.class.getName()); mPodcastFragment = (PodcastFragment) getSupportFragmentManager().getFragment(savedInstanceState, PodcastFragment.class.getName()); } if (mCommunityNewsFragment == null) { mCommunityNewsFragment = new CommunityNewsFragment(); } if (mVideosFragment == null) { mVideosFragment = new VideosFragment(); } if (mCommunityFragment == null) { mCommunityFragment = new CommunityFragment(); } if (mTwitterStreamFragment == null) { mTwitterStreamFragment = new TwitterStreamFragment(); } if (mPodcastFragment == null) { mPodcastFragment = new PodcastFragment(); } //Initialize sharedPrefs mPrefs = getSharedPreferences(CommunityHubConfig.PREFS_NAME, Context.MODE_PRIVATE); mLastTimeApiRequestsMade = mPrefs.getLong("lastTimeApiRequestsMade", 0); // Instantiate a ViewPager and a PagerAdapter. mPager = (ViewPager) findViewById(R.id.pager); HomePagerAdapter mPagerAdapter = new HomePagerAdapter(getSupportFragmentManager()); mPager.setAdapter(mPagerAdapter); mNumFragments = mPagerAdapter.getCount(); mPager.setPageTransformer(true, new DepthPageTransformer()); //mNumFragments = mPagerAdapter.getCount(); // Getting an array of link names mNavDrawerLinks = getResources().getStringArray(R.array.navdrawer_links); // Title of the activity // = (String)getTitle(); // Getting a reference to the drawer listview mDrawerList = (ListView) findViewById(R.id.drawer_list); final TypedArray styledAttributes = this.getTheme() .obtainStyledAttributes(new int[] { android.R.attr.actionBarSize }); int mActionBarSize = (int) styledAttributes.getDimension(0, 0); styledAttributes.recycle(); mDrawerList.setPadding(0, mActionBarSize, 0, 0); // Getting a reference to the sidebar drawer ( Title + ListView ) mDrawer = (LinearLayout) findViewById(R.id.drawer); mList = new ArrayList<HashMap<String, String>>(); for (int i = 0; i < 5; i++) { HashMap<String, String> hm = new HashMap<String, String>(); hm.put(TITLE, mNavDrawerLinks[i]); hm.put(ICON, Integer.toString(mIcons[i])); mList.add(hm); } // Keys used in Hashmap String[] from = { ICON, TITLE }; // Ids of views in listview_layout int[] to = { R.id.icon, R.id.title }; // Instantiating an adapter to store each items // R.layout.drawer_layout defines the layout of each item mAdapter = new SimpleAdapter(this, mList, R.layout.drawer_layout, from, to) { @Override public View getView(int position, View convertView, ViewGroup parent) { View view = super.getView(position, convertView, parent); TextView textView = (TextView) view.findViewById(R.id.title); textView.setTextColor(Color.WHITE); return view; } }; mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); // Creating a ToggleButton for NavigationDrawer with drawer event listener mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { /** Called when drawer is closed */ public void onDrawerClosed(View view) { getActionBar().setTitle(R.string.app_name); supportInvalidateOptionsMenu(); } /** Called when a drawer is opened */ public void onDrawerOpened(View drawerView) { getActionBar().setTitle(R.string.title_nav_opened); supportInvalidateOptionsMenu(); } }; // Setting event listener for the drawer mDrawerLayout.setDrawerListener(mDrawerToggle); // ItemClick event handler for the drawer items mDrawerList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) { // Increment hit count of the drawer list item //incrementHitCount(position); if (position <= mNumFragments) { // Show fragment showFragment(position); } // Closing the drawer mDrawerLayout.closeDrawer(mDrawer); } }); // Setting the adapter to the listView mDrawerList.setAdapter(mAdapter); PagerTabStrip strip = (PagerTabStrip) findViewById(R.id.pagertitlestrip); strip.setDrawFullUnderline(true); strip.setTabIndicatorColor(Color.WHITE); strip.setNonPrimaryAlpha(0.5f); strip.setTextSpacing(25); strip.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); /* Sliding Panel Layout Setup */ mSlidingLayout.setShadowDrawable(getResources().getDrawable(R.drawable.above_shadow)); //mSlidingLayout.setAnchorPoint(0.3f); mSlidingLayout.setDragView(mDraggableView); mSlidingLayout.setPanelSlideListener(new PanelSlideListener() { @Override public void onPanelSlide(View panel, float slideOffset) { if (slideOffset < 0.2) { if (getActionBar().isShowing()) { getActionBar().hide(); } } else { if (!getActionBar().isShowing()) { getActionBar().show(); } } } @Override public void onPanelExpanded(View panel) { } @Override public void onPanelCollapsed(View panel) { } @Override public void onPanelAnchored(View panel) { } }); //Initially hide the podcast panel mPodcastPanel.setVisibility(View.GONE); mHasMadeCommunityNewsRequest = savedInstanceState == null ? false : savedInstanceState.getBoolean(KEY_HAS_MADE_COMMUNITY_NEWS_FEED_REQUEST, false); mHasMadeTwitterFeedRequest = savedInstanceState == null ? false : savedInstanceState.getBoolean(KEY_HAS_MADE_TWITTER_FEED_REQUEST, false); mHasMadePodcastsRequest = savedInstanceState == null ? false : savedInstanceState.getBoolean(KEY_HAS_MADE_PODCAST_FEED_REQUEST, false); boolean actionBarHidden = savedInstanceState != null ? savedInstanceState.getBoolean(SAVED_STATE_ACTION_BAR_HIDDEN, false) : false; if (actionBarHidden) { getActionBar().hide(); } }