Java Code Examples for android.support.v7.widget.AppCompatImageView#setOnClickListener()
The following examples show how to use
android.support.v7.widget.AppCompatImageView#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: RecyclerViewBanner.java From RecyclerViewBanner with Apache License 2.0 | 6 votes |
@Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { AppCompatImageView img = new AppCompatImageView(parent.getContext()); RecyclerView.LayoutParams params = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); img.setLayoutParams(params); img.setId(R.id.rvb_banner_image_view_id); img.setScaleType(AppCompatImageView.ScaleType.CENTER_CROP); img.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (onRvBannerClickListener != null) { onRvBannerClickListener.onClick(currentIndex % mData.size()); } } }); return new RecyclerView.ViewHolder(img) { }; }
Example 2
Source File: PhotoLayout.java From nono-android with GNU General Public License v3.0 | 6 votes |
private void initImgContainer(){ LinearLayout linearLayout=new LinearLayout(getContext()); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); imageView=new AppCompatImageView(getContext()); LinearLayout.LayoutParams lp=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); imageView.setLayoutParams(lp); linearLayout.addView(imageView); imageView.setOnClickListener(this); editText=new AppCompatEditText(getContext()); linearLayout.addView(editText); editText.setVisibility(GONE); editText.setTextAppearance(getContext(),R.style.NoteTextAppearance); editText.setGravity(Gravity.CENTER); editText.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if(keyCode==KeyEvent.KEYCODE_DEL&&editText.getText().toString().isEmpty()){ editText.setVisibility(GONE); } return false; } }); this.addView(linearLayout); }
Example 3
Source File: SideBarArrow.java From AndroidSideBar with Apache License 2.0 | 5 votes |
public LinearLayout getView(Context context,boolean left,WindowManager windowManager,SideBarService sideBarService) { mContext = context; mLeft = left; mWindowManager = windowManager; mSideBarService = sideBarService; mParams = new WindowManager.LayoutParams(); // compatible if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { mParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; } else { mParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT; } // set bg transparent mParams.format = PixelFormat.RGBA_8888; // can not focusable mParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; mParams.x = 0; mParams.y = 0; // window size mParams.width = ViewGroup.LayoutParams.WRAP_CONTENT; mParams.height = ViewGroup.LayoutParams.WRAP_CONTENT; // get layout LayoutInflater inflater = LayoutInflater.from(context); mArrowView = (LinearLayout) inflater.inflate(R.layout.layout_arrow, null); AppCompatImageView arrow = mArrowView.findViewById(R.id.arrow); arrow.setOnClickListener(this); if(left) { arrow.setRotation(180); mParams.gravity = Gravity.START | Gravity.CENTER_VERTICAL; mParams.windowAnimations = R.style.LeftSeekBarAnim; }else { mParams.gravity = Gravity.END | Gravity.CENTER_VERTICAL; mParams.windowAnimations = R.style.RightSeekBarAnim; } mWindowManager.addView(mArrowView,mParams); return mArrowView; }