List of usage examples for android.widget AdapterView getContext
@ViewDebug.CapturedViewProperty public final Context getContext()
From source file:tinygsn.gui.android.ActivityViewDataNew.java
public void loadVSList() { spinnerVS = (Spinner) findViewById(R.id.spinner_vs); List<String> list = new ArrayList<String>(); for (String s : vsNameList) { list.add(s);// w w w . ja va 2 s .c o m } ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, R.layout.spinner_item, list); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinnerVS.setAdapter(dataAdapter); int index = 0; if (vsNameFromExtra != null) { for (String s : vsNameList) { if (s.equals(vsNameFromExtra)) { spinnerVS.setSelection(index); } index++; } } spinnerVS.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { vsName = parent.getItemAtPosition(pos).toString(); Toast.makeText(parent.getContext(), "The virtual sensor \"" + vsName + "\" is selected.", Toast.LENGTH_SHORT).show(); controller.loadListFields(parent.getItemAtPosition(pos).toString()); } @Override public void onNothingSelected(AdapterView<?> arg0) { Toast.makeText(context, "Please select a virtual sensor", Toast.LENGTH_SHORT).show(); } }); }
From source file:com.flipzu.flipzu.ListingsFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mFrom = null;//from ww w .j a va 2 s . co m /* init Google Analytics tracker */ initGATracker(); /* event notifier */ if (mListType == fi.FRIENDS) { this.setEmptyText(getText(R.string.loading)); EventNotifier.getInstance().setEventFriends(this); } else if (mListType == fi.ALL) { this.setEmptyText(getText(R.string.loading)); EventNotifier.getInstance().setEventAll(this); } else if (mListType == fi.PROFILE) { this.setEmptyText(getText(R.string.loading)); EventNotifier.getInstance().setEventProfile(this); } else if (mListType == fi.USER) { this.setEmptyText(getText(R.string.loading)); EventNotifier.getInstance().setEventUser(this); } else if (mListType == fi.HOTTEST) { this.setEmptyText(getText(R.string.loading)); EventNotifier.getInstance().setEventHot(this); } else if (mListType == fi.SEARCH) { this.setEmptyText(""); EventNotifier.getInstance().setEventSearch(this); } /* restore settings object */ settings = getSupportActivity().getApplicationContext().getSharedPreferences(PREFS_NAME, 0); if (savedInstanceState != null && mListType == fi.USER) { String username = savedInstanceState.getString("mUser"); String token = settings.getString("token", null); AsyncFlipInterface.getUser(username, token, this); } mBcasts = new ArrayList<BroadcastDataSet>(); if (mListType == fi.USER) { this.mAdapter = new BcastAdapter(getSupportActivity().getApplicationContext(), R.layout.bcast_row_user, mBcasts); } else { this.mAdapter = new BcastAdapter(getSupportActivity().getApplicationContext(), R.layout.bcast_row, mBcasts); } setListAdapter(this.mAdapter); refreshListing(); getListView().setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { if (mListType == fi.PROFILE) { final CharSequence[] items = { getString(R.string.delete_broadcast) }; final int pos = position; AlertDialog.Builder builder = new AlertDialog.Builder(parent.getContext()); builder.setItems(items, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { String id = mBcasts.get(pos).getId(); deleteBroadcast(id); } }); AlertDialog alert = builder.create(); alert.setCanceledOnTouchOutside(true); alert.show(); return true; } return true; } }); getListView().setOnScrollListener(this); }
From source file:org.hfoss.posit.android.plugin.csv.CsvListFindsFragment.java
/** * Puts the items from the DB table into the rows of the view. *//*from www. j ava 2s . c om*/ private void fillList(ListAdapter adapter) { setListAdapter(adapter); ListView lv = getListView(); lv.setTextFilterEnabled(true); lv.setOnItemClickListener(new OnItemClickListener() { /** * Returns the expedition Id to the TrackerActivity */ public void onItemClick(AdapterView<?> parent, View view, int position, long id) { int find_id = Integer.parseInt((String) ((TextView) view.findViewById(R.id.id)).getText()); Find find = new Find(); find.setName((String) ((TextView) view.findViewById(R.id.name)).getText()); find.setDescription((String) ((TextView) view.findViewById(R.id.description_id)).getText()); find.setLatitude( Double.parseDouble((String) ((TextView) view.findViewById(R.id.latitude)).getText())); find.setLongitude( Double.parseDouble((String) ((TextView) view.findViewById(R.id.longitude)).getText())); Intent intent = new Intent(parent.getContext(), CsvFindActivity.class); find.setGuid((String) ((TextView) view.findViewById(R.id.id)).getText()); intent.setAction(ACTION_CSV_FINDS); intent.putExtra(ACTION_CSV_FINDS, Integer.parseInt(find.getGuid())); // CsvFind use integer guids, 1, 2, 3 ... intent.putExtra("findbundle", find.getDbEntries()); startActivity(intent); } }); }
From source file:org.brandroid.openmanager.fragments.ContentFragment.java
public void onItemClick(AdapterView<?> list, View view, int pos, long id) { OpenPath file = (OpenPath) list.getItemAtPosition(pos); Logger.LogInfo("File clicked: " + file.getPath()); if (file.isArchive() && file instanceof OpenFile && Preferences.Pref_Zip_Internal) file = new OpenZip((OpenFile) file); if (getClipboard().isMultiselect()) { if (getClipboard().contains(file)) { getClipboard().remove(file); if (getClipboard().size() == 0) getClipboard().stopMultiselect(); ((BaseAdapter) list.getAdapter()).notifyDataSetChanged(); } else {/* w w w. j a v a 2 s .c o m*/ //Animation anim = Animation. /* Drawable dIcon = ((ImageView)view.findViewById(R.id.content_icon)).getDrawable(); if(dIcon instanceof BitmapDrawable) { IconAnimationPanel panel = new IconAnimationPanel(getExplorer()) .setIcon(((BitmapDrawable)dIcon).getBitmap()) .setStart(new Point(view.getLeft(), view.getRight())) .setEnd(new Point(getActivity().getWindow().getWindowManager().getDefaultDisplay().getWidth() / 2, getActivity().getWindowManager().getDefaultDisplay().getHeight())) .setDuration(500); ((ViewGroup)getView()).addView(panel); } */ addToMultiSelect(file); ((TextView) view.findViewById(R.id.content_text)).setTextAppearance(list.getContext(), R.style.Highlight); } return; } if (file.isDirectory() && !mActionModeSelected) { /* if (mThumbnail != null) { mThumbnail.setCancelThumbnails(true); mThumbnail = null; } */ //setContentPath(file, true); getExplorer().onChangeLocation(file); } else if (!file.isDirectory() && !mActionModeSelected) { if (file.requiresThread() && FileManager.hasOpenCache(file.getAbsolutePath())) { //getExplorer().showToast("Still need to handle this."); if (file.isTextFile()) getExplorer().editFile(file); else { showCopyFromNetworkDialog(file); //getEventHandler().copyFile(file, mPath, mContext); } return; } else if (file.isTextFile() && Preferences.Pref_Text_Internal) getExplorer().editFile(file); else if (!IntentManager.startIntent(file, getExplorer(), Preferences.Pref_Intents_Internal)) getExplorer().editFile(file); } }
From source file:org.brandroid.openmanager.fragments.ContentFragment.java
public boolean createContextMenu(final OpenPath file, final AdapterView<?> list, final View view, final int pos, final int xOffset, final int yOffset) { Logger.LogInfo(getClassName() + ".onItemLongClick: " + file); final OpenContextMenuInfo info = new OpenContextMenuInfo(file); if (!OpenExplorer.USE_PRETTY_CONTEXT_MENUS) { if (Build.VERSION.SDK_INT > 10) { final PopupMenu pop = new PopupMenu(view.getContext(), view); pop.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { if (onOptionsItemSelected(item)) { pop.dismiss();/* w ww . j a va 2s. c o m*/ return true; } else if (getExplorer() != null) return getExplorer().onIconContextItemSelected(pop, item, item.getMenuInfo(), view); return false; } }); pop.getMenuInflater().inflate(R.menu.context_file, pop.getMenu()); onPrepareOptionsMenu(pop.getMenu()); if (DEBUG) Logger.LogDebug("PopupMenu.show()"); pop.show(); return true; } else return list.showContextMenu(); } else if (OpenExplorer.BEFORE_HONEYCOMB || !OpenExplorer.USE_ACTIONMODE) { try { //View anchor = view; //view.findViewById(R.id.content_context_helper); //if(anchor == null) anchor = view; //view.measure(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); //Rect r = new Rect(view.getLeft(),view.getTop(),view.getMeasuredWidth(),view.getMeasuredHeight()); MenuBuilder cmm = IconContextMenu.newMenu(list.getContext(), R.menu.context_file); if (!file.canRead()) { MenuUtils.setMenuEnabled(cmm, false); MenuUtils.setMenuEnabled(cmm, true, R.id.menu_context_info); } MenuUtils.setMenuEnabled(cmm, file.canWrite(), R.id.menu_context_paste, R.id.menu_context_cut, R.id.menu_context_delete, R.id.menu_context_rename); onPrepareOptionsMenu(cmm); //if(!file.isArchive()) hideItem(cmm, R.id.menu_context_unzip); if (getClipboard().size() > 0) MenuUtils.setMenuVisible(cmm, false, R.id.menu_multi); else MenuUtils.setMenuVisible(cmm, false, R.id.menu_context_paste); MenuUtils.setMenuEnabled(cmm, !file.isDirectory(), R.id.menu_context_edit, R.id.menu_context_view); final IconContextMenu cm = new IconContextMenu(list.getContext(), cmm, view); //cm.setAnchor(anchor); cm.setNumColumns(2); cm.setOnIconContextItemSelectedListener(getExplorer()); cm.setInfo(info); cm.setTextLayout(R.layout.context_item); cm.setTitle(file.getName()); if (!cm.show()) //r.left, r.top); return list.showContextMenu(); else return true; } catch (Exception e) { Logger.LogWarning("Couldn't show Iconified menu.", e); return list.showContextMenu(); } } if (!OpenExplorer.BEFORE_HONEYCOMB && OpenExplorer.USE_ACTIONMODE) { if (!file.isDirectory() && mActionMode == null && !getClipboard().isMultiselect()) { try { Method mStarter = getActivity().getClass().getMethod("startActionMode"); mActionMode = mStarter.invoke(getActivity(), new ActionModeHelper.Callback() { //@Override public boolean onPrepareActionMode(android.view.ActionMode mode, Menu menu) { return false; } //@Override public void onDestroyActionMode(android.view.ActionMode mode) { mActionMode = null; mActionModeSelected = false; } //@Override public boolean onCreateActionMode(android.view.ActionMode mode, Menu menu) { mode.getMenuInflater().inflate(R.menu.context_file, menu); mActionModeSelected = true; return true; } //@Override public boolean onActionItemClicked(android.view.ActionMode mode, MenuItem item) { //ArrayList<OpenPath> files = new ArrayList<OpenPath>(); //OpenPath file = mLastPath.getChild(mode.getTitle().toString()); //files.add(file); if (item.getItemId() != R.id.menu_context_cut && item.getItemId() != R.id.menu_multi && item.getItemId() != R.id.menu_context_copy) { mode.finish(); mActionModeSelected = false; } return executeMenu(item.getItemId(), mode, file); } }); Class cAM = Class.forName("android.view.ActionMode"); Method mST = cAM.getMethod("setTitle", CharSequence.class); mST.invoke(mActionMode, file.getName()); } catch (Exception e) { Logger.LogError("Error using ActionMode", e); } } return true; } if (file.isDirectory() && mActionMode == null && !getClipboard().isMultiselect()) { if (!OpenExplorer.BEFORE_HONEYCOMB && OpenExplorer.USE_ACTIONMODE) { try { Method mStarter = getActivity().getClass().getMethod("startActionMode"); mActionMode = mStarter.invoke(getActivity(), new ActionModeHelper.Callback() { //@Override public boolean onPrepareActionMode(android.view.ActionMode mode, Menu menu) { return false; } //@Override public void onDestroyActionMode(android.view.ActionMode mode) { mActionMode = null; mActionModeSelected = false; } //@Override public boolean onCreateActionMode(android.view.ActionMode mode, Menu menu) { mode.getMenuInflater().inflate(R.menu.context_file, menu); menu.findItem(R.id.menu_context_paste).setEnabled(getClipboard().size() > 0); //menu.findItem(R.id.menu_context_unzip).setEnabled(mHoldingZip); mActionModeSelected = true; return true; } //@Override public boolean onActionItemClicked(android.view.ActionMode mode, MenuItem item) { return executeMenu(item.getItemId(), mode, file); } }); Class cAM = Class.forName("android.view.ActionMode"); Method mST = cAM.getMethod("setTitle", CharSequence.class); mST.invoke(mActionMode, file.getName()); } catch (Exception e) { Logger.LogError("Error using ActionMode", e); } } return true; } return false; }
From source file:com.sunmeng.educationaladministration.animateview.GoogleCardsActivity.java
/** * Item??// w w w. j a v a2 s .c o m */ public void getDetails() { listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { final Map<String, Object> map; map = (Map<String, Object>) parent.getItemAtPosition(position); LayoutInflater inflater1 = getLayoutInflater(); View view1 = inflater1.inflate(R.layout.activity_extra_detailsinfo, (ViewGroup) findViewById(R.id.toast_layout)); final Spinner spn_extraclassName = (Spinner) view1.findViewById(R.id.spn_uextraclassName); final TextView tv_date = (TextView) view1.findViewById(R.id.ued_date_reply); final EditText et_teacher = (EditText) view1.findViewById(R.id.et_uextrateacher); final EditText et_jointeacher = (EditText) view1.findViewById(R.id.et_uextrajoin); final EditText et_address = (EditText) view1.findViewById(R.id.et_uaddress); final TextView tv_update_reply = (TextView) view1.findViewById(R.id.tvUpdate); final EditText et_uatime = (EditText) view1.findViewById(R.id.et_uatime); img_back = (ImageView) view1.findViewById(R.id.ivBack); img_back.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.cancel(); } }); /** * ??? */ httpUtils.send(HttpRequest.HttpMethod.GET, HttpClientUtil.HTTP_URL + "ClassAllServlet", new RequestCallBack() { @Override public void onSuccess(final ResponseInfo responseInfo) { //Toast.makeText(mContext, responseInfo.toString(), Toast.LENGTH_LONG).show(); final List<String> list = new ArrayList<String>(); list.add("cnname"); list.add("cnid"); new AsyncTask<String, String, Map<String, String>>() { @Override protected Map<String, String> doInBackground(String... params) { classNameArr = JsonUtil .getJsonToSpinnerListMap(responseInfo.result.toString(), list); return classNameArr; } @Override protected void onPostExecute(Map<String, String> s) { //android.R.layout.simple_spinner_dropdown_item// //R.layout.myspinner spn_extraclassName.setAdapter( new android.widget.ArrayAdapter<String>(GoogleCardsActivity.this, android.R.layout.simple_spinner_dropdown_item, Utils.getMapListToListString(s))); if (map.get("cnname").toString() != "") { spn_extraclassName.setSelection( Utils.getMapListId(s, map.get("cnname").toString())); spn_extraclassName.setEnabled(false); } else { } // et_classname_reply.setSelection(2, true); } }.execute(""); } @Override public void onFailure(HttpException e, String s) { } }); et_teacher.setText(map.get("ateacher").toString()); et_jointeacher.setText(map.get("ajointeacher").toString()); et_address.setText(map.get("aaddress").toString()); tv_date.setText(map.get("adate").toString()); et_uatime.setText(map.get("atime").toString()); tv_update_reply.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (tv_update_reply.getText().equals("")) { setClickble(true); tv_update_reply.setText("?"); } else if (tv_update_reply.getText().equals("?")) { setClickble(false); tv_update_reply.setText(""); // TODO ?? updateReply(); } } /** * ?? */ private void setClickble(boolean flag) { et_teacher.setEnabled(flag); et_jointeacher.setEnabled(flag); et_address.setEnabled(flag); spn_extraclassName.setEnabled(flag); et_uatime.setEnabled(flag); } public void updateReply() { String etteacher = et_teacher.getText().toString().trim(); String etjointeacher = et_jointeacher.getText().toString().trim(); String ettime = et_uatime.getText().toString().trim(); String etaddress = et_address.getText().toString().trim(); String tvdate = tv_date.getText().toString().trim(); String classnumid = classNameArr .get(spn_extraclassName.getSelectedItem().toString().trim());//?id String id = map.get("aid").toString(); //Toast.makeText(GoogleCardsActivity.this, "="+etteacher+etjointeacher+ettime+etaddress, Toast.LENGTH_SHORT).show(); if ("".equals(etteacher) && "".equals(etjointeacher) && "".equals(etaddress)) { Toast.makeText(GoogleCardsActivity.this, "???", Toast.LENGTH_SHORT) .show(); return; } else { RequestParams params = new RequestParams(); params.addBodyParameter("activitiesupcdate", tvdate); params.addBodyParameter("activitiesuptime", ettime); params.addBodyParameter("activitiesupclassnumid", classnumid); params.addBodyParameter("activitiesupteacher", etteacher); params.addBodyParameter("activitiesupjointeacher", etjointeacher); params.addBodyParameter("activitiesupaddress", etaddress); params.addBodyParameter("activitiesuprid", id); Toast.makeText(GoogleCardsActivity.this, "id==" + id, Toast.LENGTH_SHORT).show(); httpUtils.send(HttpRequest.HttpMethod.POST, HttpClientUtil.HTTP_URL + "ActivitiesUpdateServlet", params, new RequestCallBack() { @Override public void onSuccess(ResponseInfo responseInfo) { Toast.makeText(GoogleCardsActivity.this, "?", Toast.LENGTH_SHORT).show(); getData(); dialog.cancel(); } @Override public void onFailure(HttpException e, String s) { Toast.makeText(GoogleCardsActivity.this, "", Toast.LENGTH_SHORT).show(); } }); } } }); builder = new AlertDialog.Builder(parent.getContext()); builder.setView(view1); dialog = builder.create(); dialog.show(); } }); }