Java Code Examples for android.widget.ImageView#setOnClickListener()
The following examples show how to use
android.widget.ImageView#setOnClickListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TutorialLayout.java From Tutors with Apache License 2.0 | 6 votes |
private void initCross(Context context) { ImageView cross = new ImageView(context); LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); layoutParams.gravity = Gravity.TOP | Gravity.END; cross.setLayoutParams(layoutParams); cross.setImageDrawable(completeIcon); this.addView(cross); cross.setOnClickListener(new OnClickListener() { public final void onClick(View it) { if (TutorialLayout.this.tutorialListener != null) { TutorialLayout.this.tutorialListener.onCompleteAll(); } } }); }
Example 2
Source File: PopWindowActivity.java From LLApp with Apache License 2.0 | 6 votes |
@Override protected void onInitView() { setTitle("弹出框界面"); toolbar.setNavigationIcon(R.mipmap.abc_ic_ab_back_mtrl_am_alpha); toolbar.setNavigationOnClickListener(v -> finish()); mButton1 = (TextView) findViewById(R.id.button1); mButton1.setOnClickListener(this); mButton2 = (TextView) findViewById(R.id.button2); mButton2.setOnClickListener(this); mButton3 = (TextView) findViewById(R.id.button3); mButton3.setOnClickListener(this); mButton4 = (TextView) findViewById(R.id.button4); mButton4.setOnClickListener(this); imageView = (ImageView) findViewById(R.id.iv_start); imageView.setOnClickListener(this); }
Example 3
Source File: Pictures.java From ploggy with GNU General Public License v3.0 | 6 votes |
public static boolean loadThumbnailWithClickToShowPicture(Context context, File source, ImageView target) { if (!loadThumbnail(context, source, target)) { return false; } // On click ImageView, load activity with full picture final Context finalContext = context; final String finalFilePath = source.getAbsolutePath(); target.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(finalContext, ActivityShowPicture.class); Bundle bundle = new Bundle(); bundle.putString(ActivityShowPicture.FILE_PATH_BUNDLE_KEY, finalFilePath); intent.putExtras(bundle); finalContext.startActivity(intent); } }); return true; }
Example 4
Source File: HomeActivity.java From apollo-DuerOS with Apache License 2.0 | 6 votes |
private void initView() { mLoginText = (TextView) findViewById(R.id.tv_personal_center); mUpgradeRedDotView = findViewById(R.id.personal_center_red_dot); mPhoneText = (TextView) findViewById(R.id.tv_phone); mRadioText = (TextView) findViewById(R.id.tv_radio); mVideoText = (TextView) findViewById(R.id.tv_video); mMoreText = (TextView) findViewById(R.id.tv_more); mSettingText = (TextView) findViewById(R.id.tv_setting); mNetworkImg = (ImageView) findViewById(R.id.img_network); mGpsImg = (ImageView) findViewById(R.id.img_gps); mBtImg = (ImageView) findViewById(R.id.img_bt); mVoiceView = (ImageView) findViewById(R.id.voice_bt); mLoginText.setOnClickListener(this); mPhoneText.setOnClickListener(this); mRadioText.setOnClickListener(this); mVideoText.setOnClickListener(this); mMoreText.setOnClickListener(this); mSettingText.setOnClickListener(this); mVoiceView.setOnClickListener(this); }
Example 5
Source File: ShareContainer.java From ActSwitchAnimTool with Apache License 2.0 | 5 votes |
private void init() { mFaceBookItem = (ShareItemView) findViewById(R.id.item_facebook); mTwitterItem = (ShareItemView) findViewById(R.id.item_twitter); mGooglePlusItem = (ShareItemView) findViewById(R.id.item_google); mCancelV = (ImageView) findViewById(R.id.img_cancel); mCancelV.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mIShareCallback != null) { mIShareCallback.onCancel(); } } }); }
Example 6
Source File: ImageViewPagerActivity.java From Jide-Note with MIT License | 5 votes |
private void initWidget() { backImg = (ImageView) findViewById(R.id.nav_back_img); imgCountTv = (TextView) findViewById(R.id.nav_count_tv); removeImg = (ImageView) findViewById(R.id.nav_remove_img); backImg.setOnClickListener(this); removeImg.setOnClickListener(this); viewPager = (ViewPager) findViewById(R.id.nav_image_viewpager); }
Example 7
Source File: ArtistView.java From Popeens-DSub with GNU General Public License v3.0 | 5 votes |
public ArtistView(Context context) { super(context); LayoutInflater.from(context).inflate(R.layout.basic_list_item, this, true); titleView = (TextView) findViewById(R.id.item_name); starButton = (ImageButton) findViewById(R.id.item_star); starButton.setFocusable(false); moreButton = (ImageView) findViewById(R.id.item_more); moreButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { v.showContextMenu(); } }); }
Example 8
Source File: AgentWebX5Fragment.java From AgentWebX5 with Apache License 2.0 | 5 votes |
protected void initView(View view) { mBackImageView = (ImageView) view.findViewById(iv_back); mLineView = view.findViewById(R.id.view_line); mFinishImageView = (ImageView) view.findViewById(R.id.iv_finish); mTitleTextView = (TextView) view.findViewById(R.id.toolbar_title); mBackImageView.setOnClickListener(mOnClickListener); mFinishImageView.setOnClickListener(mOnClickListener); pageNavigator(View.GONE); }
Example 9
Source File: MainActivity.java From arcgis-runtime-samples-android with Apache License 2.0 | 5 votes |
/** * Create a Layout for callout */ private void createCallout() { // create content text view for the callout mCalloutLayout = new RelativeLayout(getApplicationContext()); TextView calloutContent = new TextView(getApplicationContext()); calloutContent.setId(R.id.calloutTextView); calloutContent.setTextColor(Color.BLACK); calloutContent.setTextSize(18); RelativeLayout.LayoutParams relativeParamsBelow = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); relativeParamsBelow.addRule(RelativeLayout.BELOW, calloutContent.getId()); // create attachment text view for the callout TextView calloutAttachment = new TextView(getApplicationContext()); calloutAttachment.setId(R.id.attachTextView); calloutAttachment.setTextColor(Color.BLACK); calloutAttachment.setTextSize(13); calloutContent.setPadding(0, 20, 20, 0); calloutAttachment.setLayoutParams(relativeParamsBelow); RelativeLayout.LayoutParams relativeParamsRightOf = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); relativeParamsRightOf.addRule(RelativeLayout.RIGHT_OF, calloutAttachment.getId()); // create image view for the callout ImageView imageView = new ImageView(getApplicationContext()); imageView.setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_info)); imageView.setLayoutParams(relativeParamsRightOf); imageView.setOnClickListener(new ImageViewOnclickListener()); mCalloutLayout.addView(calloutContent); mCalloutLayout.addView(imageView); mCalloutLayout.addView(calloutAttachment); }
Example 10
Source File: VerFullLiveUI.java From likequanmintv with Apache License 2.0 | 5 votes |
private void initPlayer() { mPlayBean = (PlayBean) getIntent().getSerializableExtra("playBean"); mSurfaceView = (SurfaceView) findViewById(R.id.mSurfaceView); bgImg = (ImageView) findViewById(R.id.bgImg); loadingView = (LoadindImageView) findViewById(R.id.loadingView); imgBack = (ImageView) findViewById(R.id.imgBack); imgBack.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onBackPressed(); } }); mCodec = getIntent().getIntExtra("mediaCodec", 0); // mVideoPath = getIntent().getStringExtra("videoPath"); }
Example 11
Source File: BaseFragmentWithTitleBar.java From BigApp_WordPress_Android with Apache License 2.0 | 5 votes |
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); View rl_title_bar = view.findViewById(R.id.layout_title_bar); mTv_title = (TextView) rl_title_bar.findViewById(R.id.tv_title); mIv_left = (ImageView) rl_title_bar.findViewById(R.id.iv_left); mIv_right = (ImageView) rl_title_bar.findViewById(R.id.iv_right); mIv_left.setVisibility(View.GONE); mIv_left.setOnClickListener(this); mIv_right.setOnClickListener(this); mFl_ads = view.findViewById(R.id.fl_ads); initSwitcher(); findAndBindViews(view); }
Example 12
Source File: PlacePickerActivity.java From mapbox-plugins-android with BSD 2-Clause "Simplified" License | 5 votes |
private void addBackButtonListener() { ImageView backButton = findViewById(R.id.mapbox_place_picker_toolbar_back_button); backButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finish(); } }); }
Example 13
Source File: BasicExplainPopupWindow.java From allenglish with Apache License 2.0 | 5 votes |
private void initView() { word = (TextView) contentView.findViewById(R.id.word); symbols = (TextView) contentView.findViewById(R.id.symbols); collection = (ImageView) contentView.findViewById(R.id.collection); collection.setOnClickListener(this); close = (ImageButton) contentView.findViewById(R.id.close); close.setOnClickListener(this); sound = (LinearLayout) contentView.findViewById(R.id.sound); sound.setOnClickListener(this); }
Example 14
Source File: FloatMeasurementView.java From openScale with GNU General Public License v3.0 | 5 votes |
@Override public void onBindViewHolder(PreferenceViewHolder holder) { super.onBindViewHolder(holder); ImageView helpView = (ImageView)holder.findViewById(R.id.helpView); helpView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { getContext().startActivity(new Intent( Intent.ACTION_VIEW, Uri.parse("https://github.com/oliexdev/openScale/wiki/Body-metric-estimations"))); } }); }
Example 15
Source File: MainActivity.java From journaldev with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // setting image resource from drawable ImageView imageView = (ImageView) findViewById(R.id.imageView2); imageView.setImageResource(R.drawable.balloon); imageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Toast.makeText(getApplicationContext(), "Clicked Second Image", Toast.LENGTH_SHORT).show(); } }); ImageButton imageButton=(ImageButton) findViewById(R.id.imageButton); imageButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Toast.makeText(getApplicationContext(), "Clicked Image Button", Toast.LENGTH_SHORT).show(); } }); Bitmap bMap = BitmapFactory.decodeResource(getResources(), R.drawable.balloon); // Resize the bitmap to 150x100 (width x height) Bitmap bMapScaled = Bitmap.createScaledBitmap(bMap, 350, 300, true); // Loads the resized Bitmap into an ImageView ImageView image = (ImageView) findViewById(R.id.imageView5); image.setImageBitmap(bMapScaled); }
Example 16
Source File: LeftMenuActivity.java From LLApp with Apache License 2.0 | 4 votes |
private void initDrawer() { ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.open_nav_drawer, R.string.close_nav_drawer); drawer.setDrawerListener(toggle); drawer.setFitsSystemWindows(true); drawer.setClipToPadding(false); toggle.syncState(); if (navigationView != null) { // StatusBarUtil.setColorNoTranslucentForDrawerLayout(MainActivity.this,drawer,getColor(R.color.black)); // navigationView.setNavigationItemSelectedListener(this); // navigationView.setItemIconTintList(ColorStateList.valueOf(StaticValue.color)); // navigationView.setCheckedItem(R.id.nav_home); // navigationView.setItemTextColor(ColorStateList.valueOf(StaticValue.color)); } //这里为了兼容4.4及以下版本 navigationView.inflateHeaderView(R.layout.nav_header_main); View headerView = navigationView.getHeaderView(0); ImageView ivAvatar = (ImageView) headerView.findViewById(R.id.iv_avatar); // Glides.getInstance().loadCircle(this,R.mipmap.ai1,ivAvatar); ImageLoader imageLoader = new ImageLoader.Builder() .imgView(ivAvatar) .placeHolder(R.mipmap.ai1) .url("https://ss3.baidu.com/-fo3dSag_xI4khGko9WTAnF6hhy/image/h%3D360/sign=caa2d267cfef7609230b9f991edca301/6d81800a19d8bc3e7763d030868ba61ea9d345e5.jpg") .build(); ImageLoaderUtil.getInstance().loadCircleImage(this,imageLoader); LinearLayout llNavHomepage = (LinearLayout) headerView.findViewById(R.id.ll_nav_homepage); LinearLayout llNavShare = (LinearLayout) headerView.findViewById(R.id.ll_nav_share); RelativeLayout llNavMode = (RelativeLayout) headerView.findViewById(R.id.ll_nav_mode); LinearLayout llNavSet = (LinearLayout) headerView.findViewById(R.id.ll_nav_set); ImageView nav_main_img = (ImageView) headerView.findViewById(R.id.nav_main_img); TextView nav_main_text = (TextView) headerView.findViewById(R.id.nav_main_text); ImageView nav_share_img = (ImageView) headerView.findViewById(R.id.nav_share_img); TextView nav_share_text = (TextView) headerView.findViewById(R.id.nav_share_text); ImageView nav_mode_img = (ImageView) headerView.findViewById(R.id.nav_mode_img); TextView nav_mode_text = (TextView) headerView.findViewById(R.id.nav_mode_text); ToggleButton toggleButton = (ToggleButton) headerView.findViewById(R.id.toggle_mode); ImageView nav_set_img = (ImageView) headerView.findViewById(R.id.nav_set_img); TextView nav_set_text = (TextView) headerView.findViewById(R.id.nav_set_text); toggleButton.setOnColor(StaticValue.color); if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ MDTintUtil.setTint(nav_main_img,StaticValue.color); nav_main_text.setTextColor(StaticValue.color); MDTintUtil.setTint(nav_share_img,StaticValue.color); nav_share_text.setTextColor(StaticValue.color); MDTintUtil.setTint(nav_mode_img,StaticValue.color); nav_mode_text.setTextColor(StaticValue.color); MDTintUtil.setTint(nav_set_img,StaticValue.color); nav_set_text.setTextColor(StaticValue.color); } llNavHomepage.setOnClickListener(this); llNavShare.setOnClickListener(this); llNavMode.setOnClickListener(this); llNavSet.setOnClickListener(this); toggleButton.setOnToggleChanged(on -> { if(on){ showMessage("切换到夜间模式"); }else { showMessage("切换到正常模式"); } }); // View header = navigationView.getHeaderView(0); // navBgView = (RelativeLayout) header.findViewById(R.id.nav_head_bg); // headImg = (ImageView) header.findViewById(R.id.nav_header); // navBgView.setBackgroundResource(R.mipmap.b_1); // Glides.getInstance().loadCircle(this,R.mipmap.ai1,headImg); ivAvatar.setOnClickListener(view -> { startActivity(PersonActivity.class); drawer.closeDrawer(GravityCompat.START); }); }
Example 17
Source File: PenStrockAndColorSelect.java From ScaleSketchPadDemo with MIT License | 4 votes |
public void initialize(Context context) { this.setBackgroundColor(Color.WHITE); final int width = 90; final int height = 90; final int margin = 13; final int length = PointPath.mPathColors.length; int left = 10; for (int i = 0; i < length; ++i) { int color = PointPath.mPathColors[i]; ImageView imgBtn = new ImageView(context); if (CURRENT_TYPE == STROCK_TYPE) { Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_4444); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(); paint.setColor(Color.RED); paint.setStrokeWidth(PointPath.mPenStrock[i]); canvas.drawLine(0, height, width, 0, paint); imgBtn.setImageBitmap(bitmap); imgBtn.setBackgroundColor(Color.WHITE); } else { imgBtn.setBackgroundColor(color); } imgBtn.setOnClickListener(m_clickListener); imgBtn.setTag(i); LayoutParams params = new LayoutParams(width, height); params.setMargins(left, 30, 0, 0); params.addRule(Gravity.CENTER_VERTICAL); left += (margin + width); this.addView(imgBtn, params); } // Cancel button. Button btnCancel = new Button(context); btnCancel.setText("cancel"); btnCancel.setId(CANCEL_BUTTON_ID); btnCancel.setTextSize(8); btnCancel.setOnClickListener(m_clickListener); LayoutParams btnCancelparams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, height); btnCancelparams.addRule(Gravity.CENTER); left += 10; btnCancelparams.setMargins(left, 30, 0, 0); this.addView(btnCancel, btnCancelparams); }
Example 18
Source File: DynamicAdapter.java From Android-Application-ZJB with Apache License 2.0 | 4 votes |
private void updateLikeLayout(List<String> avatars, LinearLayout mLikeLayout, boolean needPadding) { if (ValidateUtil.isValidate(avatars)) { int count = 0; int sWidth = gContext.getResources().getDisplayMetrics().widthPixels; int firstElementMarginLeft = Math.round(gContext.getResources() .getDimension(R.dimen.like_author_margin)); int contentWidth = sWidth - 2 * firstElementMarginLeft; int imageWidth = Math.round(contentWidth / (((LIKE_COUNT) - 1) * 0.4167f + LIKE_COUNT)); int marginLeft = Math.round(imageWidth * 0.4167f); mLikeLayout.setVisibility(View.VISIBLE); mLikeLayout.setOrientation(LinearLayout.HORIZONTAL); mLikeLayout.removeAllViews(); for (int i = 0; i < avatars.size(); i++) { String avatar = avatars.get(i); if (TextUtils.isEmpty(avatar)) { continue; } LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(imageWidth, imageWidth); if (needPadding) { params.leftMargin = count > 0 ? marginLeft : firstElementMarginLeft; } else { if (i != 0) { params.leftMargin = count > 0 ? marginLeft : firstElementMarginLeft; } } if (count >= LIKE_COUNT - 1) { int num = avatars.size(); View view = getMoreImageView(num + ""); mLikeLayout.addView(view, params); view.setOnClickListener(v -> { ViewUtils.setDelayedClickable(v, 800); }); break; } else { ImageView likeImageView = getLikeImageView(avatar); mLikeLayout.addView(likeImageView, params); likeImageView.setOnClickListener(v -> { ViewUtils.setDelayedClickable(v, 800); }); } count++; } } }
Example 19
Source File: DrawerActivity.java From MaterialWeCenter with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_drawer); ButterKnife.bind(this); setSupportActionBar(toolbar); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.addDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); TextView textViewTitle = navigationView.getHeaderView(0).findViewById(R.id.textView); TextView textViewEmail = navigationView.getHeaderView(0).findViewById(R.id.textViewEmail); ImageView imageViewAvatar = navigationView.getHeaderView(0).findViewById(R.id.imageView); imageViewAvatar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(DrawerActivity.this, UserActivity.class); intent.putExtra("uid", uid); startActivity(intent); } }); // 验证用户保存的登录信息 SharedPreferences preferences = getSharedPreferences("account", MODE_PRIVATE); uid = preferences.getInt(Config.PRE_UID, -1); user_name = preferences.getString(Config.PRE_USER_NAME, ""); avatar_file = preferences.getString(Config.PRE_AVATAR_FILE, ""); String email = preferences.getString(Config.PRE_EMAIL, ""); // 加载用户头像/用户名 if (!avatar_file.isEmpty()) Picasso.with(this).load(avatar_file).into(imageViewAvatar); textViewTitle.setText(user_name); textViewEmail.setText(email); // 加载动态页面 homeFragment = new HomeFragment(); FragmentTransaction tx = getSupportFragmentManager().beginTransaction(); tx.add(R.id.container, homeFragment); tx.commit(); setTitle(R.string.dynamic); }
Example 20
Source File: MessageAdapter.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 4 votes |
/** * 展示视频缩略图 * * @param localThumb * 本地缩略图路径 * @param iv * @param thumbnailUrl * 远程缩略图路径 * @param message */ private void showVideoThumbView(String localThumb, ImageView iv, String thumbnailUrl, final EMMessage message) { // first check if the thumbnail image already loaded into cache Bitmap bitmap = ImageCache.getInstance().get(localThumb); if (bitmap != null) { // thumbnail image is already loaded, reuse the drawable iv.setImageBitmap(bitmap); iv.setClickable(true); iv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { VideoMessageBody videoBody = (VideoMessageBody) message .getBody(); System.err.println("video view is on click"); Intent intent = new Intent(activity, ShowVideoActivity.class); intent.putExtra("localpath", videoBody.getLocalUrl()); intent.putExtra("secret", videoBody.getSecret()); intent.putExtra("remotepath", videoBody.getRemoteUrl()); if (message != null && message.direct == EMMessage.Direct.RECEIVE && !message.isAcked && message.getChatType() != ChatType.GroupChat) { message.isAcked = true; try { EMChatManager.getInstance().ackMessageRead( message.getFrom(), message.getMsgId()); } catch (Exception e) { e.printStackTrace(); } } activity.startActivity(intent); } }); } else { new LoadVideoImageTask().execute(localThumb, thumbnailUrl, iv, activity, message, this); } }