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:markson.visuals.sitapp.eventActivity.java
public void json() { ListAdapter adapter = new SimpleAdapter(this, mylist, R.layout.jsontest, new String[] { "name", "description" }, new int[] { R.id.item_title, R.id.item_subtitle }); setListAdapter(adapter);//from w ww .ja va 2 s . c o m final ListView lv = getListView(); lv.setTextFilterEnabled(true); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { @SuppressWarnings("unchecked") HashMap<String, String> o = (HashMap<String, String>) lv.getItemAtPosition(position); // Toast.makeText(eventActivity.this,"ID '" + o.get("link") + // "' was clicked.",Toast.LENGTH_SHORT).show(); TextView title = (TextView) findViewById(R.id.item_title); Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/roboto/Roboto-Regular.ttf"); title.setTypeface(tf); TextView subtitle = (TextView) findViewById(R.id.item_subtitle); subtitle.setTypeface(tf); date = o.get("pubDate"); link = o.get("link"); description = o.get("description"); name = o.get("name"); download(); } }); }
From source file:com.example.android.animationsdemo.GirdPagerSearchBarActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_screen_slide); LayoutInflater inflater = getLayoutInflater(); // Inner ViewPager View headerview = inflater.inflate(R.layout.gridview_header, null); mInnerPager = (SlideFirstViewPager) headerview.findViewById(R.id.inner_pager); mPrev = (Button) findViewById(R.id.prev); mNext = (Button) findViewById(R.id.next); mHeaderGridView = (HeaderGridView) findViewById(R.id.gridView); ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>(); for (int i = 0; i < mPlaces.length; i++) { HashMap<String, String> item = new HashMap<String, String>(); item.put("food", mPlaces[i]); item.put("place", mPlaces[i]); list.add(item);// w w w . ja va2s.c om } SimpleAdapter adapter = new SimpleAdapter(this, list, android.R.layout.simple_list_item_2, new String[] { "food", "place" }, new int[] { android.R.id.text1, android.R.id.text2 }); TextAdapter mAdapter = new TextAdapter(); mPrev.setOnClickListener(this); mNext.setOnClickListener(this); mPagerAdapter = new ScreenSlidePagerAdapter(getFragmentManager(), VIDEO_PATHS); mInnerPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { DKLog.d(TAG, Trace.getCurrentMethod() + position); mPagerAdapter.setFocus(position); invalidateOptionsMenu(); } @Override public void onPageScrollStateChanged(int state) { } }); mInnerPager.setAdapter(mPagerAdapter); mInnerPager.setOffscreenPageLimit(NUM_PAGES); TextView mTextView = new TextView(getApplicationContext()); mTextView.setText("OOOOOOOOOOOOOOOOOOOOO"); mTextView.setTextSize(10); mTextView.setSingleLine(true); mHeaderGridView.addHeaderView(headerview, "ViewPager"); mHeaderGridView.setAdapter(mAdapter); mHeaderGridView.setNumColumns(3); // Start Download // for(int i = 0 ; i < VIDEO_PATHS.length ; i++) { // DownloadService.downloadVideo(context, VIDEO_PATHS[i], new DownloadReceiver(new Handler())); // } }
From source file:br.unisinos.evertonlucas.passshelter.app.UsersNewGroupActivity.java
public void loadListAdapter(ListView listView, List<ParseUser> emailList, int resource) { String[] from = { "email" }; int[] to = { R.id.txt_user_new_group }; SimpleAdapter adapter = new SimpleAdapter(this, listResources(emailList), resource, from, to); listView.setAdapter(adapter);/*from w w w. ja v a 2 s .c o m*/ }
From source file:at.alladin.rmbt.android.fragments.history.RMBTHistoryFragment.java
@Override public void historyUpdated(final int status) { if (!isVisible()) return;/*from ww w. j a v a2s . c o m*/ switch (status) { case SUCCESSFUL: historyList = new SimpleAdapter(getActivity(), activity.getHistoryItemList(), R.layout.history_item, new String[] { "device", "type", "date", "down", "up", "ping" }, new int[] { R.id.device, R.id.type, R.id.date, R.id.down, R.id.up, R.id.ping }); listView.setAdapter(historyList); listView.setSelectionFromTop(listViewIdx, listViewTop); Log.d(DEBUG_TAG, "set: idx:" + listViewIdx + " top:" + listViewTop); listView.invalidate(); progessBar.setVisibility(View.GONE); emptyView.setVisibility(View.GONE); listView.setVisibility(View.VISIBLE); break; case LIST_EMPTY: Log.i(DEBUG_TAG, "LEERE LISTE"); progessBar.setVisibility(View.GONE); emptyView.setVisibility(View.VISIBLE); emptyView.setText(getString(R.string.error_no_data)); emptyView.invalidate(); break; case ERROR: Log.i(DEBUG_TAG, "FEHLER"); progessBar.setVisibility(View.GONE); emptyView.setVisibility(View.VISIBLE); emptyView.setText(getString(R.string.error_history_no_data_no_connection)); emptyView.invalidate(); break; } }
From source file:com.otaupdater.KernelTab.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); adapter = new SimpleAdapter(getActivity(), DATA, R.layout.two_line_icon_list_item, new String[] { KEY_TITLE, KEY_SUMMARY, KEY_ICON }, new int[] { android.R.id.text1, android.R.id.text2, android.R.id.icon }); setListAdapter(adapter);//w w w.j a va 2s . co m }
From source file:com.yeldi.yeldibazaar.ManageRepo.java
private void redraw() { try {/*from ww w. j av a 2s.c om*/ DB db = DB.getDB(); repos = db.getRepos(); } finally { DB.releaseDB(); } List<Map<String, Object>> result = new ArrayList<Map<String, Object>>(); Map<String, Object> server_line; for (DB.Repo repo : repos) { server_line = new HashMap<String, Object>(); server_line.put("address", repo.address); if (repo.inuse) { server_line.put("inuse", R.drawable.btn_check_on); } else { server_line.put("inuse", R.drawable.btn_check_off); } if (repo.pubkey != null) { try { MessageDigest digest = MessageDigest.getInstance("SHA-1"); digest.update(Hasher.unhex(repo.pubkey)); byte[] fingerprint = digest.digest(); Formatter formatter = new Formatter(new StringBuilder()); formatter.format("%02X", fingerprint[0]); for (int i = 1; i < fingerprint.length; i++) { formatter.format(i % 5 == 0 ? " %02X" : ":%02X", fingerprint[i]); } server_line.put("fingerprint", formatter.toString()); formatter.close(); } catch (Exception e) { Log.w("FDroid", "Unable to get certificate fingerprint.\n" + Log.getStackTraceString(e)); } } result.add(server_line); } SimpleAdapter show_out = new SimpleAdapter(this, result, R.layout.repolisticons, new String[] { "address", "inuse", "fingerprint" }, new int[] { R.id.uri, R.id.img, R.id.fingerprint }); setListAdapter(show_out); }
From source file:com.rastating.droidbeard.fragments.ComingEpisodesFragment.java
@Override public void onApiRequestFinished(SickbeardAsyncTask sender, UpcomingEpisode[] result) { if (activityStillExists()) { if (result != null) { mEpisodes = result;/*w w w. ja va 2s .c om*/ ArrayList<Map<String, String>> data = new ArrayList<Map<String, String>>(); Preferences preferences = new Preferences(getActivity()); if (preferences.getEmphasizeShowNameFlag()) { for (UpcomingEpisode episode : result) { HashMap<String, String> item = new HashMap<String, String>(); item.put("name", episode.getShowName()); item.put("desc", String.format("%s - %dx%d - %s", episode.getAirdateString("yyyy-MM-dd"), episode.getSeasonNumber(), episode.getEpisodeNumber(), episode.getName())); data.add(item); } } else { for (UpcomingEpisode episode : result) { HashMap<String, String> item = new HashMap<String, String>(); item.put("name", episode.getName()); item.put("desc", String.format("%s - %dx%d - %s", episode.getShowName(), episode.getSeasonNumber(), episode.getEpisodeNumber(), episode.getAirdateString("yyyy-MM-dd"))); data.add(item); } } String[] from = new String[] { "name", "desc" }; int[] to = new int[] { R.id.episode, R.id.event_details }; final UpcomingEpisode[] episodes = result; mAdapter = 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); switch (episodes[position].getUpcomingStatus()) { case CURRENT: view.setBackgroundColor(getResources().getColor(R.color.upcoming_episode_current)); break; case DISTANT: view.setBackgroundColor(getResources().getColor(R.color.upcoming_episode_distant)); break; case FUTURE: view.setBackgroundColor(getResources().getColor(R.color.upcoming_episode_future)); break; case PAST: view.setBackgroundColor(getResources().getColor(R.color.upcoming_episode_past)); break; } return view; } }; setAdapter(mAdapter); showListView(); } else { showError(getString(R.string.error_fetching_coming_episodes), sender.getLastException()); } } }
From source file:com.cgearc.yummy.Act_Main.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); setContentView(R.layout.act_main);// w ww. ja va 2 s . com mAdView = (AdView) findViewById(R.id.ad); AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .addTestDevice("1E172019E4D41AF1A4ED0C07934364B0").build(); mAdView.loadAd(adRequest); mTitle = mDrawerTitle = getTitle(); mDrawerItems = getResources().getStringArray(R.array.drawer_item_array); // now 3 mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); // set a custom shadow that overlays the main content when the drawer // opens mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view with items and click listener int[] image = { R.drawable.ic_menu_home, R.drawable.ic_action_search, R.drawable.ic_action_favorite, R.drawable.ic_action_about, R.drawable.ic_action_good }; List<Map<String, Object>> items = new ArrayList<Map<String, Object>>(); for (int i = 0; i < image.length; i++) { Map<String, Object> item = new HashMap<String, Object>(); item.put("image", image[i]); item.put("text", mDrawerItems[i]); items.add(item); } SimpleAdapter simpleAdapter = new SimpleAdapter(this, items, R.layout.drawer_list_item, new String[] { "image", "text" }, new int[] { R.id.drawer_image, R.id.drawer_text }); mDrawerList.setAdapter(simpleAdapter); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); // enable ActionBar app icon to behave as action to toggle nav drawer getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); // ActionBarDrawerToggle ties together the the proper interactions // between the sliding drawer and the action bar app icon mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* 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(mTitle); invalidateOptionsMenu(); // creates call to // onPrepareOptionsMenu() } public void onDrawerOpened(View drawerView) { getActionBar().setTitle(mDrawerTitle); invalidateOptionsMenu(); // creates call to // onPrepareOptionsMenu() } @Override public void onDrawerSlide(View drawerView, float slideOffset) { BaseFragment fragment = (BaseFragment) Act_Main.this.getFragmentManager() .findFragmentById(R.id.content_frame); if (fragment != null) { fragment.stepBack(slideOffset); } } }; mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { selectItem(0); } // SlidingUP ---start--- mSUPTitle = (TextView) findViewById(R.id.title); mSUPTitle.setText("Welcome Yummy!"); mSUPAuthor = (TextView) findViewById(R.id.author); mSUPAuthor.setText("Click above recipe and view detail here"); mSlideUpPanel = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout); mDragView = (LinearLayout) this.findViewById(R.id.dragView); mSlideUpPanel.setDragView(mDragView); mSlideUpPanel.setPanelSlideListener(new PanelSlideListener() { @Override public void onPanelSlide(View panel, float slideOffset) { } @Override public void onPanelExpanded(View panel) { Log.i(TAG, "onPanelExpanded"); mImageButtonWeb.setVisibility(View.VISIBLE); mImageButtonClose.setVisibility(View.VISIBLE); toggleHideyBar(); // TODO: switch text with head and actionbar title // String title = mSUPTitle.getText().toString(); // mSUPTitle.setText(getActionBar().getTitle()); // setTitle(title); // mDragView.setVisibility(View.GONE); } @Override public void onPanelCollapsed(View panel) { Log.i(TAG, "onPanelCollapsed"); toggleHideyBar(); // getActionBar().show(); mImageButtonWeb.setVisibility(View.INVISIBLE); mImageButtonClose.setVisibility(View.INVISIBLE); // TODO: switch text with head and actionbar title // String title = mSUPTitle.getText().toString(); // mSUPTitle.setText(getActionBar().getTitle()); // setTitle(title); // mDragView.setVisibility(View.VISIBLE); } @Override public void onPanelAnchored(View panel) { Log.i(TAG, "onPanelAnchored"); } }); // boolean actionBarHidden = savedInstanceState != null // && savedInstanceState.getBoolean(SAVED_STATE_ACTION_BAR_HIDDEN, // false); // if (actionBarHidden) { // int actionBarHeight = getActionBarHeight(); // setActionBarTranslation(-actionBarHeight);// will "hide" an // // ActionBar // } // SlidingUP ----end---- // Detail Frame Head ----start---- mImageButtonClose = (ImageButton) findViewById(R.id.close); mImageButtonWeb = (ImageButton) findViewById(R.id.web); mImageButtonClose.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mSlideUpPanel.collapsePane(); } }); // Detail Frame head -----end----- }
From source file:me.chenjiayang.myleancloud.CarItemActivity.java
private void setAdapter() { //SimpleAdapter SimpleAdapter adapter = new SimpleAdapter(this, list, R.layout.list_car_info_elem, from, to); //ListActivitysetListAdapterListView? listView.setAdapter(adapter);/* w w w .j a v a2 s .c o m*/ listView.setOnItemClickListener(new ListItemClickListener()); /** * * ??LogoidR.id.home */ getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(false); //??? car_qr_btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { final Bitmap bitmap = EncodingHandler.createQRCode(carinfo, 900); final ImageView imageView = new ImageView(CarItemActivity.this); imageView.setImageBitmap(bitmap); builder = new AlertDialog.Builder(CarItemActivity.this); alert = builder.setView(imageView) .setNegativeButton("?", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create(); alert.show(); } catch (WriterException e) { ToastUtil.show(CarItemActivity.this, "??"); } } }); car_delete_bound_btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //sweet dialog new SweetAlertDialog(CarItemActivity.this, SweetAlertDialog.WARNING_TYPE) .setTitleText("Are you sure?").setContentText("Won't be able to recover this car!") .setConfirmText("Yes,delete it!") .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { @Override public void onClick(SweetAlertDialog sDialog) { sDialog.setTitleText("Deleted!") .setContentText("Your imaginary car has been deleted!").setConfirmText("OK") .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { @Override public void onClick(SweetAlertDialog sweetAlertDialog) { sweetAlertDialog.dismiss(); } }).changeAlertType(SweetAlertDialog.SUCCESS_TYPE); AVQuery<AVObject> avQuery = new AVQuery<>("Car"); avQuery.getInBackground(bundle_id.getString("ObjectId"), new GetCallback<AVObject>() { @Override public void done(AVObject avObject, AVException e) { if (AVUser.getCurrentUser().getString("NowDriving") .equals(bundle_id.getString("ObjectId"))) { AVUser auser = AVUser.getCurrentUser(); auser.put("NowDriving", ""); auser.saveInBackground(); } avObject.deleteInBackground(); ToastUtil.show(CarItemActivity.this, "?"); } }); } }).show(); } }); }
From source file:com.agiro.scanner.android.CaptureActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); Log.d(TAG, "onCreate"); Window window = getWindow();/*from ww w .j ava 2s. c o m*/ window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.capture); this.eraseButton = (Button) this.findViewById(R.id.erase); this.eraseButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { reference = null; amount = null; account = null; debug = null; populateList(reference, amount, account, debug); onContentChanged(); } }); this.sendButton = (Button) this.findViewById(R.id.send); this.sendButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { } }); this.scanButton = (Button) this.findViewById(R.id.scan); this.scanButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { handler.sendEmptyMessage(R.id.restart_preview); } }); SimpleAdapter adapter = new SimpleAdapter(this, list, R.layout.result_list_item, new String[] { "data_type", "data" }, new int[] { R.id.data_type, R.id.data }); populateList(reference, amount, account, debug); setListAdapter(adapter); CameraManager.init(getApplication()); viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view); handler = null; hasSurface = false; // inactivityTimer = new InactivityTimer(this); }