本文整理了Java中android.widget.ImageView.setOnClickListener()
方法的一些代码示例,展示了ImageView.setOnClickListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageView.setOnClickListener()
方法的具体详情如下:
包路径:android.widget.ImageView
类名称:ImageView
方法名:setOnClickListener
暂无
代码示例来源:origin: TommyLemon/APIJSON
@SuppressLint("InflateParams")
@Override
public View getLeftMenu(Activity activity) {
if (leftMenu == null) {
leftMenu = (ImageView) LayoutInflater.from(activity).inflate(R.layout.top_right_iv, null);
leftMenu.setImageResource(R.drawable.add);
leftMenu.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
onDragBottom(false);
}
});
}
return leftMenu;
}
代码示例来源:origin: aa112901/remusic
ListItemViewHolder(View view) {
super(view);
this.mainTitle = (TextView) view.findViewById(R.id.viewpager_list_toptext);
this.title = (TextView) view.findViewById(R.id.viewpager_list_bottom_text);
this.playState = (ImageView) view.findViewById(R.id.play_state);
this.moreOverflow = (ImageView) view.findViewById(R.id.viewpager_list_button);
moreOverflow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MoreFragment morefragment = MoreFragment.newInstance(mList.get(getAdapterPosition() - 1).id + "", IConstants.MUSICOVERFLOW);
morefragment.show(getSupportFragmentManager(), "music");
}
});
view.setOnClickListener(this);
}
代码示例来源:origin: stackoverflow.com
// Catch event on [x] button inside search view
int searchCloseButtonId = searchView.getContext().getResources()
.getIdentifier("android:id/search_close_btn", null, null);
ImageView closeButton = (ImageView) this.searchView.findViewById(searchCloseButtonId);
// Set on click listener
closeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Manage this event.
}
});
代码示例来源:origin: CarGuo/GSYVideoPlayer
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
if (convertView == null) {
holder = new ViewHolder();
convertView = inflater.inflate(R.layout.list_video_simple_mode2, null);
holder.videoContainer = (FrameLayout) convertView.findViewById(R.id.list_item_container);
holder.playerBtn = (ImageView) convertView.findViewById(R.id.list_item_btn);
holder.imageView = new ImageView(context);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
//增加封面
holder.imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
holder.imageView.setImageResource(R.mipmap.xxx1);
smallVideoHelper.addVideoPlayer(position, holder.imageView, TAG, holder.videoContainer, holder.playerBtn);
holder.playerBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
notifyDataSetChanged();
smallVideoHelper.setPlayPositionAndTag(position, TAG);
final String url = "http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4";
gsySmallVideoHelperBuilder.setVideoTitle("title " + position)
.setUrl(url);
smallVideoHelper.startPlay();
}
});
return convertView;
}
代码示例来源:origin: stackoverflow.com
super(itemLayoutView);
mListener = listener;
txtViewTitle = (TextView) itemLayoutView.findViewById(R.id.item_title);
imgViewIcon = (ImageView) itemLayoutView.findViewById(R.id.item_icon);
imgViewIcon.setOnClickListener(this);
itemLayoutView.setOnClickListener(this);
代码示例来源:origin: CarGuo/GSYVideoPlayer
holder = new ViewHolder();
convertView = inflater.inflate(R.layout.list_video_item, null);
holder.videoContainer = (FrameLayout) convertView.findViewById(R.id.list_item_container);
holder.playerBtn = (ImageView) convertView.findViewById(R.id.list_item_btn);
holder.imageView = new ImageView(context);
convertView.setTag(holder);
holder.imageView.setImageResource(R.mipmap.xxx1);
smallVideoHelper.addVideoPlayer(position, holder.imageView, TAG, holder.videoContainer, holder.playerBtn);
holder.playerBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
代码示例来源:origin: TommyLemon/APIJSON
@SuppressLint("InflateParams")
@Override
public View getRightMenu(Activity activity) {
if (rightMenu == null) {
rightMenu = (ImageView) LayoutInflater.from(activity).inflate(R.layout.top_right_iv, null);
rightMenu.setImageResource(R.drawable.search);
rightMenu.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
onDragBottom(true);
}
});
}
return rightMenu;
}
代码示例来源:origin: stackoverflow.com
closeButton.setOnClickListener(new View.OnClickListener() {
代码示例来源:origin: aa112901/remusic
ListItemViewHolder(View view) {
super(view);
this.mainTitle = (TextView) view.findViewById(R.id.viewpager_list_toptext);
this.title = (TextView) view.findViewById(R.id.viewpager_list_bottom_text);
this.playState = (TintImageView) view.findViewById(R.id.play_state);
this.moreOverflow = (ImageView) view.findViewById(R.id.viewpager_list_button);
moreOverflow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MoreFragment morefragment = MoreFragment.newInstance(mList.get(getAdapterPosition() - 1), IConstants.MUSICOVERFLOW);
morefragment.show(getFragmentManager(), "music");
}
});
view.setOnClickListener(this);
}
代码示例来源:origin: HotBitmapGG/bilibili-android-client
/**
* 初始化NavigationView
*/
private void initNavigationView() {
mNavigationView.setNavigationItemSelectedListener(this);
View headerView = mNavigationView.getHeaderView(0);
CircleImageView mUserAvatarView = (CircleImageView) headerView.findViewById(R.id.user_avatar_view);
TextView mUserName = (TextView) headerView.findViewById(R.id.user_name);
TextView mUserSign = (TextView) headerView.findViewById(R.id.user_other_info);
ImageView mSwitchMode = (ImageView) headerView.findViewById(R.id.iv_head_switch_mode);
//设置头像
mUserAvatarView.setImageResource(R.drawable.ic_hotbitmapgg_avatar);
//设置用户名 签名
mUserName.setText(getResources().getText(R.string.hotbitmapgg));
mUserSign.setText(getResources().getText(R.string.about_user_head_layout));
//设置日夜间模式切换
mSwitchMode.setOnClickListener(v -> switchNightMode());
boolean flag = PreferenceUtil.getBoolean(ConstantUtil.SWITCH_MODE_KEY, false);
if (flag) {
mSwitchMode.setImageResource(R.drawable.ic_switch_daily);
} else {
mSwitchMode.setImageResource(R.drawable.ic_switch_night);
}
}
代码示例来源:origin: TommyLemon/APIJSON
@SuppressLint("InflateParams")
@Override
public View getRightMenu(Activity activity) {
if (rightMenu == null) {
rightMenu = (ImageView) LayoutInflater.from(activity).inflate(R.layout.top_right_iv, null);
rightMenu.setImageResource(R.drawable.search);
rightMenu.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
onDragBottom(true);
}
});
}
return rightMenu;
}
代码示例来源:origin: stackoverflow.com
public class MainActivity extends Activity {
private ImageView image;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
image = (ImageView) findViewById(R.id.image);
image.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Animation anim = new MyAnimation(image, 100);
anim.setDuration(3000);
image.startAnimation(anim);
}
});
}
}
代码示例来源:origin: aa112901/remusic
ListItemViewHolder(View view) {
super(view);
this.mainTitle = (TextView) view.findViewById(R.id.viewpager_list_toptext);
this.title = (TextView) view.findViewById(R.id.viewpager_list_bottom_text);
this.playState = (ImageView) view.findViewById(R.id.play_state);
this.moreOverflow = (ImageView) view.findViewById(R.id.viewpager_list_button);
moreOverflow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MoreFragment morefragment = MoreFragment.newInstance(mList.get(getAdapterPosition() - 1).id + "", IConstants.MUSICOVERFLOW);
morefragment.show(getFragmentManager(), "music");
}
});
view.setOnClickListener(this);
}
代码示例来源:origin: naman14/Timber
View rootView = inflater.inflate(R.layout.fragment_style_selector_pager, container, false);
TextView styleName = (TextView) rootView.findViewById(R.id.style_name);
styleName.setText(String.valueOf(getArguments().getInt(ARG_PAGE_NUMBER) + 1));
preferences = getActivity().getSharedPreferences(Constants.FRAGMENT_ID, Context.MODE_PRIVATE);
styleImage = (ImageView) rootView.findViewById(R.id.style_image);
imgLock = (ImageView) rootView.findViewById(R.id.img_lock);
styleImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
styleImage.setImageResource(R.drawable.timber_1_nowplaying_x);
break;
case 1:
styleImage.setImageResource(R.drawable.timber_2_nowplaying_x);
break;
case 2:
styleImage.setImageResource(R.drawable.timber_3_nowplaying_x);
break;
case 3:
代码示例来源:origin: CarGuo/GSYVideoPlayer
public void onBind(final int position, VideoModel videoModel) {
//增加封面
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setImageResource(R.mipmap.xxx1);
smallVideoHelper.addVideoPlayer(position, imageView, TAG, listItemContainer, listItemBtn);
listItemBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
smallVideoHelper.setPlayPositionAndTag(position, TAG);
getRecyclerBaseAdapter().notifyDataSetChanged();
//listVideoUtil.setLoop(true);
String url;
if (position % 2 == 0) {
url = "https://res.exexm.com/cw_145225549855002";
} else {
url = "http://wdquan-space.b0.upaiyun.com/VIDEO/2018/11/22/ae0645396048_hls_time10.m3u8";
}
//listVideoUtil.setCachePath(new File(FileUtils.getPath()));
gsySmallVideoHelperBuilder.setVideoTitle("title " + position).setUrl(url);
smallVideoHelper.startPlay();
//必须在startPlay之后设置才能生效
//listVideoUtil.getGsyVideoPlayer().getTitleTextView().setVisibility(View.VISIBLE);
}
});
}
代码示例来源:origin: stackoverflow.com
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
代码示例来源:origin: aa112901/remusic
ListItemViewHolder(View view) {
super(view);
this.mainTitle = (TextView) view.findViewById(R.id.viewpager_list_toptext);
this.title = (TextView) view.findViewById(R.id.viewpager_list_bottom_text);
this.playState = (TintImageView) view.findViewById(R.id.play_state);
this.moreOverflow = (ImageView) view.findViewById(R.id.viewpager_list_button);
//设置弹出菜单
moreOverflow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MoreFragment moreFragment = new MoreFragment().newInstance(mList.get(getAdapterPosition() - 1), IConstants.MUSICOVERFLOW);
moreFragment.show(getFragmentManager(), "music");
}
});
view.setOnClickListener(this);
}
代码示例来源:origin: HotBitmapGG/bilibili-android-client
private void initControllerView(View v) {
mPauseButton = (ImageButton) v.findViewById(R.id.media_controller_play_pause);
mTvPlay = (ImageView) v.findViewById(R.id.media_controller_tv_play);
if (mPauseButton != null && mTvPlay != null) {
mPauseButton.requestFocus();
mPauseButton.setOnClickListener(mPauseListener);
mTvPlay.requestFocus();
mTvPlay.setOnClickListener(v13 -> {
doPauseResume();
show(sDefaultTimeout);
});
mProgress = (SeekBar) v.findViewById(R.id.media_controller_seekbar);
if (mProgress != null) {
if (mProgress instanceof SeekBar) {
mDanmakuLayout.setOnClickListener(v1 -> {
if (mDanmakuShow) {
mDanmakuImage.setImageResource(R.drawable.bili_player_danmaku_is_open);
mDanmakuText.setText("弹幕开");
mDanmukuSwitchListener.setDanmakuShow(true);
mDanmakuShow = false;
} else {
mDanmakuImage.setImageResource(R.drawable.bili_player_danmaku_is_closed);
mDanmakuText.setText("弹幕关");
mDanmukuSwitchListener.setDanmakuShow(false);
mBack = (ImageView) v.findViewById(R.id.media_controller_back);
mBack.setOnClickListener(v12 -> mVideoBackListener.back());
代码示例来源:origin: huazhiyuan2008/RecyclerViewCardGallery
@Override
public void onBindViewHolder(final ViewHolder holder, final int position) {
mCardAdapterHelper.onBindViewHolder(holder.itemView, position, getItemCount());
holder.mImageView.setImageResource(mList.get(position));
holder.mImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ToastUtils.show(holder.mImageView.getContext(), "" + position);
}
});
}
代码示例来源:origin: aa112901/remusic
ListItemViewHolder(View view) {
super(view);
this.mainTitle = (TextView) view.findViewById(R.id.viewpager_list_toptext);
this.title = (TextView) view.findViewById(R.id.viewpager_list_bottom_text);
this.playState = (TintImageView) view.findViewById(R.id.play_state);
this.moreOverflow = (ImageView) view.findViewById(R.id.viewpager_list_button);
view.setOnClickListener(this);
//设置弹出菜单
moreOverflow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MoreFragment moreFragment = new MoreFragment().newInstance(mList.get(getAdapterPosition() - 1), IConstants.MUSICOVERFLOW);
moreFragment.show(getFragmentManager(), "music");
}
});
}
内容来源于网络,如有侵权,请联系作者删除!