List of usage examples for android.widget ImageView setOnClickListener
public void setOnClickListener(@Nullable OnClickListener l)
From source file:com.cloudbase.cbhelperdemo.DataScreen.java
@SuppressWarnings("unchecked") @Override/*from ww w . j a va2 s . co m*/ public void handleResponse(CBQueuedRequest req, CBHelperResponse res) { // we are downloading a file if (res.getFunction().equals("download")) { if (res.getDownloadedFile() != null) { try { // resize the downloaded image and display it in an ImageView BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(res.getDownloadedFile().getAbsolutePath(), options); int imageHeight = options.outHeight; int imageWidth = options.outWidth; int reqWidth = 200; int reqHeight = 200; int inSampleSize = 1; if (imageHeight > reqHeight || imageWidth > reqWidth) { if (imageWidth > imageHeight) { inSampleSize = Math.round((float) imageHeight / (float) reqHeight); } else { inSampleSize = Math.round((float) imageWidth / (float) reqWidth); } } options.inSampleSize = inSampleSize; options.inJustDecodeBounds = false; Bitmap myBitmap = BitmapFactory.decodeFile(res.getDownloadedFile().getAbsolutePath(), options); //BitmapFactory.decodeStream(new FileInputStream(res.getDownloadedFile()), options); ImageView imageView = new ImageView(this.getActivity()); imageView.setImageBitmap(myBitmap); imageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ((ViewGroup) v.getParent()).removeView(v); } }); //setting image position LayoutParams par = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); imageView.setLayoutParams(par); this.getActivity().addContentView(imageView, par); } catch (Exception ex) { Log.e("DEMOAPP", "Error while opening downloaded file", ex); } } } else { if (res.getData() instanceof List) { // if we are not downloading and just running the search then read the array of result and // print the size. Log.d("DEMOAPP", "Is is array"); AlertDialog.Builder builder = new AlertDialog.Builder(this.getActivity()); builder.setTitle("Received response"); builder.setMessage("total items: " + ((List<Object>) res.getData()).size()); builder.setPositiveButton("OK", null); builder.show(); } else { Log.d("DEMOAPP", "Data not array: " + res.getData().getClass().toString()); } } }
From source file:com.examples.abelanav2.ui.UploadFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_upload, container, false); ImageView imageView = (ImageView) view.findViewById(R.id.imageViewUploadImage); imageView.setOnClickListener(this); if (!mRetrieving) { mRetrieving = true;// w w w .ja v a 2 s . co m selectPhoto(); } return view; }
From source file:com.jacr.instagramtrendreader.ImageDetailsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup view = (ViewGroup) inflater.inflate(R.layout.frg_images_details, container, false); // Views/* w ww . j a va2s. c o m*/ TextView txtPublishDate = (TextView) view.findViewById(R.id.txtDateValue); TextView txtAuthor = (TextView) view.findViewById(R.id.txtUsernameValue); TextView txtTags = (TextView) view.findViewById(R.id.txtTagsValue); ImageView imv = (ImageView) view.findViewById(R.id.imvDetails); txtPublishDate.setText(formatearFecha(publishDate)); txtAuthor.setText(author); txtTags.setText(tags); imv.setImageURI(Uri.fromFile(new File(imagePath))); imv.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final Activity act = ImageDetailsFragment.this.getActivity(); Intent in = new Intent(act, HTMLViewer.class); Bundle b = new Bundle(); b.putString(HTMLViewer.KEY_USERNAME, author); b.putString(HTMLViewer.KEY_URL_IMAGE, urlDowloadImage); in.putExtras(b); act.startActivity(in); } }); return view; }
From source file:com.example.android.animationsdemo.BoardFragment.java
public void addItem(View view) { LayoutInflater inflater = LayoutInflater.from(getActivity()); View newCard = inflater.inflate(R.layout.new_card_layout, null, false); newCard.setTag("newCard"); ViewGroup parentCol = (ViewGroup) view.getParent(); ViewGroup svCol = (ViewGroup) parentCol.getChildAt(parentCol.getChildCount() - 1); ViewGroup containerCol = (ViewGroup) svCol.getChildAt(0); View check = containerCol.findViewWithTag("newCard"); if (check == null) containerCol.addView(newCard, 0); else/* w ww . java2 s.c o m*/ containerCol.removeView(check); ImageView save = (ImageView) newCard.findViewById(R.id.saveNewCard); final EditText title = (EditText) newCard.findViewById(R.id.newCardTitle); save.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view1) { if (isEmpty(title)) Toast.makeText(context, "Please enter a title", Toast.LENGTH_SHORT).show(); else { query = ""; pager.getAdapter().notifyDataSetChanged(); InputMethodManager imm = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(title.getWindowToken(), 0); } // } }); }
From source file:galilei.kelimekavanozu.activity.PoemHistoryActivity.java
private void setUpBack() { final ImageView back = (ImageView) findViewById(R.id.back); back.setOnClickListener(new View.OnClickListener() { @Override/*from w w w . ja v a 2s.com*/ public void onClick(View v) { onBackPressed(); } }); }
From source file:net.evecom.androidecssp.activity.event.ETypeListActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.etype_list_at); etype = null;/*from ww w. j a v a 2 s . com*/ lastRank = new ArrayList<BaseModel>(); etypeList = (ListView) findViewById(R.id.etype_listview); rl = (RelativeLayout) findViewById(R.id.etype_bottom_block); ImageView lastetype = (ImageView) findViewById(R.id.last_etype_btn); rl.setVisibility(View.GONE); lastetype.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { if (lastRank.size() > 0) { // etype = lastRank.get(lastRank.size() - 1); lastRank.remove(lastRank.size() - 1); } else { // null etype = null; } initList(); etypeAdapter.notifyDataSetChanged(); } }); initList(); }
From source file:com.easemob.ui.ContactlistFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); listView = (ListView) getView().findViewById(R.id.list); sidebar = (Sidebar) getView().findViewById(R.id.sidebar); sidebar.setListView(listView);/*w ww .ja va2 s . c o m*/ contactList = new ArrayList<User>(); //?contactlist getContactList(); //adapter adapter = new ContactAdapter(getActivity(), R.layout.row_contact, contactList, sidebar); listView.setAdapter(adapter); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String username = adapter.getItem(position).getUsername(); if (Constant.NEW_FRIENDS_USERNAME.equals(username)) { //? User user = MyApplication.getInstance().getContactList().get(Constant.NEW_FRIENDS_USERNAME); user.setUnreadMsgCount(0); startActivity(new Intent(getActivity(), NewFriendsMsgActivity.class)); } else if (Constant.GROUP_USERNAME.equals(username)) { //?? startActivity(new Intent(getActivity(), GroupsActivity.class)); } else { //demo?? startActivity(new Intent(getActivity(), ChatActivity.class).putExtra("userId", adapter.getItem(position).getUsername())); } } }); listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // ?? if (getActivity().getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getActivity().getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); ImageView addContactView = (ImageView) getView().findViewById(R.id.iv_new_contact); //? addContactView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(getActivity(), AddContactActivity.class)); } }); registerForContextMenu(listView); }
From source file:com.tafayor.selfcamerashot.devApps.DevAppDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Context ctx = getActivity(); Bundle args = getArguments();/*w w w . jav a2s . c o m*/ if (args != null && args.containsKey(ARG_APPINFO)) { mAppInfo = args.getParcelable(ARG_APPINFO); } if (mAppInfo == null) { LogHelper.logx(new Exception("DevAppDialog mAppInfo null")); Dialog dlg = new AlertDialog.Builder(ctx).create(); return dlg; } LayoutInflater inflater = getActivity().getLayoutInflater(); View rootView = inflater.inflate(R.layout.dialog_dev_app, null, false); TextView tvDescription = (TextView) rootView.findViewById(R.id.description); ImageView imageView = (ImageView) rootView.findViewById(R.id.image); ImageButton playView = (ImageButton) rootView.findViewById(R.id.play); tvDescription.setText(mAppInfo.getDescription()); imageView.setImageResource(mAppInfo.getImage()); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { MarketHelper.showProductPage(ctx, mAppInfo.getPackageName()); } }); if (mAppInfo.getYoutubeId() == null) playView.setVisibility(View.GONE); playView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { IntentHelper.openYoutubeVideo(ctx, mAppInfo.getYoutubeId()); } }); AlertDialog.Builder builder = new AlertDialog.Builder(ctx).setTitle(mAppInfo.getTitle()) .setIcon(mAppInfo.getIcon()).setView(rootView) .setPositiveButton("Google Play", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { MarketHelper.showProductPage(ctx, mAppInfo.getPackageName()); } }).setNegativeButton(android.R.string.cancel, null); AppCompatDialog dialog = (AppCompatDialog) builder.create(); return dialog; }
From source file:com.sincere.kboss.UserInfoActivity.java
void initUI() { ImageView btnBack = (ImageView) findViewById(R.id.btnBack); btnBack.setOnClickListener(new View.OnClickListener() { @Override//from w w w . j ava 2s . c o m public void onClick(View view) { //callApiSetIntro(); returnBack(null); } }); TextView btnConfirm = (TextView) findViewById(R.id.btnConfirm); btnConfirm.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { returnBack(null); } }); lblWorkingArea = (TextView) findViewById(R.id.lblWorkingArea); lblWeekday = (TextView) findViewById(R.id.lblWeekday); lblHistoryYear = (TextView) findViewById(R.id.lblHistoryYear); lblJobs = (TextView) findViewById(R.id.lblJobs); edtIntro = (EditText) findViewById(R.id.edtIntro); llIntroNext = (LinearLayout) findViewById(R.id.llIntroNext); llIntroNext.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { callApiSetIntro(); } }); lblBasicSecDate = (TextView) findViewById(R.id.lblBasicSecDate); lblPayType = (TextView) findViewById(R.id.lblPayType); lblCert = (TextView) findViewById(R.id.lblCert); lblBank = (TextView) findViewById(R.id.lblBank); pw = (ProgressWheel) findViewById(R.id.pwLoading); setupProgress(0); }
From source file:com.giangnvt.fragment.FlashcardPagerFragment.java
@Override public void configActionbarButtons() { View.OnClickListener clickListener = new View.OnClickListener() { @Override/*from w w w . ja v a 2 s. c o m*/ public void onClick(View v) { ((MainActivity) activity).openFlashcardOptionActivity(flashcardPrefKey, dataFilename == null ? entryIdList : null, dataFilename == null ? null : dataFilename, tableName, false); } }; Button flashcardOptionButton = (Button) activity.findViewById(R.id.button_actionbar_flashcard_option); ImageView flashcardOptionImage = (ImageView) activity .findViewById(R.id.imageview_actionbar_flashcard_option); flashcardOptionButton.setOnClickListener(clickListener); flashcardOptionImage.setOnClickListener(clickListener); }