Android viewpager 嵌套 viewpager滑动 点击事件冲突解决方案

为了解决这个问题。可以自定义viewpager,然后在里面监听首饰,自定义点击事件

 

package com.hpuvoice.view;

import android.content.Context;
import android.graphics.PointF;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.GestureDetector.OnGestureListener;
import android.view.MotionEvent;

public class MyViewPager extends ViewPager implements OnGestureListener {

	/** 手势滑动处理类 **/
	private GestureDetector mDetector;
	/** 触摸时按下的点 **/
	PointF downP = new PointF();
	/** 触摸时当前的点 **/
	PointF curP = new PointF();

	OnSingleTouchListener onSingleTouchListener;

	public MyViewPager(Context context, AttributeSet attrs) {
		super(context, attrs);
		GestureDetector detector = new GestureDetector(context, this);
		mDetector = detector;
	}

	public GestureDetector getGestureDetector() {
		return mDetector;
	}

	@Override
	public boolean onTouchEvent(MotionEvent arg0) {
		curP.x = arg0.getX();
		curP.y = arg0.getY();
		getParent().requestDisallowInterceptTouchEvent(true);
		if (arg0.getAction() == MotionEvent.ACTION_DOWN) {
			downP.x = arg0.getX();
			downP.y = arg0.getY();
		}

		if (arg0.getAction() == MotionEvent.ACTION_MOVE) {
			// 此句代码是为了通知他的父ViewPager现在进行的是本控件的操作,不要对我的操作进行干扰
			getParent().requestDisallowInterceptTouchEvent(true);
		}

		if (arg0.getAction() == MotionEvent.ACTION_UP) {
			// 在up时判断是否按下和松手的坐标为一个点
			// 如果是一个点,将执行点击事件,这是我自己写的点击事件,而不是onclick
			if ((downP.x == curP.x) && (downP.y == curP.y)) {
				onSingleTouch();
				return true;
			}
		}

		return super.onTouchEvent(arg0);
	}

	@Override
	public void setOnPageChangeListener(OnPageChangeListener listener) {
		super.setOnPageChangeListener(listener);
	}

	/**
	 * 单击   
	 */
	public void onSingleTouch() {
		if (onSingleTouchListener != null) {
			onSingleTouchListener.onSingleTouch();
		}
	}

	/**
	 *    * 创建点击事件接口    *   
	 */
	public interface OnSingleTouchListener {
		public void onSingleTouch();
	}

	public void setOnSingleTouchListener(
			OnSingleTouchListener onSingleTouchListener) {
		this.onSingleTouchListener = onSingleTouchListener;
	}

	@Override
	public boolean onDown(MotionEvent e) {
		return false;
	}

	@Override
	public void onShowPress(MotionEvent e) {

	}

	@Override
	public boolean onSingleTapUp(MotionEvent e) {
		return false;
	}

	@Override
	public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
			float distanceY) {
		return false;
	}

	@Override
	public void onLongPress(MotionEvent e) {

	}

	@Override
	public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
			float velocityY) {
		return false;
	}

}

  然后在使用该viewpager的类中,进行一系列监听,使用,同事本案例是为了展示首页轮播图的效果,其中另外一个点就是首页轮播图动态添加小圆点。并且实现轮播效果。

 

package com.hpuvoice.fragment;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Timer;
import java.util.TimerTask;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.edaixi.activity.CityListActivity;
import com.edaixi.activity.LoginActivity;
import com.edaixi.activity.MainActivity;
import com.edaixi.activity.PlaceorderActivity;
import com.edaixi.activity.R;
import com.edaixi.activity.WebActivity;
import com.edaixi.appdata.Kclassdata;
import com.edaixi.appdata.KeepingData;
import com.edaixi.bean.Bannerlistbean;
import com.edaixi.bean.InappUrlbean;
import com.edaixi.bean.PostCommonBean;
import com.edaixi.listadpter.Myfuncadpter;
import com.edaixi.utils.Common;
import com.edaixi.utils.DensityUtil;
import com.edaixi.utils.NetUtil;
import com.edaixi.utils.SaveUtils;
import com.edaixi.view.MySpringRing;
import com.edaixi.view.MyViewPager.OnSingleTouchListener;
import com.google.gson.Gson;
import com.lidroid.xutils.BitmapUtils;

public class HomeFragment extends BaseFragment implements OnClickListener {
	private static final int GETBANNERFAILD = 2;
	private static final int GETBANNERSUCCED = 3;
	private static final int GETFUNCTIONBTNSUCCED = 4;
	private static final int GETFUNCTIONBTNFAILD = 5;
	boolean RequstFlag = false;
	private View view;
	private Button main_order_btn;
	private HashMap<String, String> parms;
	private SaveUtils saveUtils;
	private String address = "";
	private GridView main_grid;
	private Myfuncadpter adapter;
	private com.edaixi.view.MyViewPager myview_pager;
	private ImageView anim_trousers;
	private ImageView anim_womencloth;
	private ImageView anim_clothsmall;
	private ImageView imageView_title;
	private ArrayList<Bannerlistbean> funditonlist;
	private JSONObject str;
	private TitleAdapter title;
	private Animation tosmallanimation;
	private ImageView anim_sleeveshort;
	private ArrayList<Bannerlistbean> banerlistbak;
	private LinearLayout pager_bottom;
	private int Animorder;
	private MySpringRing cricleView;
	private ImageView point;
	private static TextView loction_text;
	private int currentPosition = 0;
	private boolean is_Loop_Flag = true;;

	@SuppressLint("HandlerLeak")
	private Handler handler = new Handler() {
		private Gson gson = new Gson();

		@Override
		public void handleMessage(Message msg) {
			myview_pager.setCurrentItem(currentPosition);
			currentPosition++;
			if ((banerlistbak.size() > 0)
					&& (currentPosition > banerlistbak.size() - 1)) {
				currentPosition = (currentPosition % banerlistbak.size());
			}
			if (is_Loop_Flag) {
				handler.sendEmptyMessageDelayed(0, 3000);
			}
			try {
				switch (msg.what) {
				case GETBANNERSUCCED:
					PostCommonBean jsonCommonBean = gson.fromJson(
							(String) msg.obj, PostCommonBean.class);
					if (jsonCommonBean.isRet()) {
						String data = jsonCommonBean.getData();
						banerlistbak = null;
						banerlistbak = new ArrayList<Bannerlistbean>();
						paserbaner(data, banerlistbak);
						myview_pager.setCurrentItem(0);
						currentPosition = Integer.MAX_VALUE / 2
								- (Integer.MAX_VALUE / 2 % banerlistbak.size());
						addBannerPoint();
						TitleAdapter titlebak = new TitleAdapter(banerlistbak);
						myview_pager.setAdapter(titlebak);
						titlebak.notifyDataSetChanged();
					}
					break;
				case GETBANNERFAILD:
					break;
				case GETFUNCTIONBTNSUCCED:
					RequstFlag = true;
					PostCommonBean CommonBean = gson.fromJson((String) msg.obj,
							PostCommonBean.class);
					if (CommonBean.isRet()) {
						String data = CommonBean.getData();
						paserbaner(data, funditonlist);
						adapter.notifyDataSetChanged();
					}
					break;
				case GETFUNCTIONBTNFAILD:
					break;
				}
				super.handleMessage(msg);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	};

	@SuppressLint("HandlerLeak")
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		view = (LinearLayout) inflater.inflate(R.layout.fragment_home,
				container, false);
		main_order_btn = (Button) view.findViewById(R.id.main_order_btn);
		main_grid = (GridView) view.findViewById(R.id.main_grid);
		myview_pager = (com.edaixi.view.MyViewPager) view
				.findViewById(R.id.myview_pager);
		cricleView = (MySpringRing) view.findViewById(R.id.myring_circle);
		cricleView.startAnim();
		pager_bottom = (LinearLayout) view.findViewById(R.id.pager_bottom);
		anim_trousers = (ImageView) view.findViewById(R.id.anim_trousers);
		anim_womencloth = (ImageView) view.findViewById(R.id.anim_womencloth);
		anim_clothsmall = (ImageView) view.findViewById(R.id.anim_clothsmall);
		anim_sleeveshort = (ImageView) view.findViewById(R.id.anim_sleeveshort);
		loction_text = (TextView) view.findViewById(R.id.loction_text);
		loction_text.setOnClickListener(this);

		myview_pager.setCurrentItem(currentPosition);
		myview_pager.setOnPageChangeListener(new OnPageChangeListener() {
			@Override
			public void onPageSelected(int position) {
				currentPosition = position;
				if (pager_bottom.getChildCount() > 0) {
					for (int i = 0; i < banerlistbak.size(); i++) {
						pager_bottom.getChildAt(i).setBackgroundResource(
								getImageResIDs()[0]);
					}
					pager_bottom.getChildAt(position).setBackgroundResource(
							getImageResIDs()[1]);
				}
			}

			@Override
			public void onPageScrollStateChanged(int arg0) {
			}

			@Override
			public void onPageScrolled(int arg0, float arg1, int arg2) {
			}
		});

		myview_pager.setOnSingleTouchListener(new OnSingleTouchListener() {

			@Override
			public void onSingleTouch() {
				Intent intent = new Intent();
				if (banerlistbak.get(myview_pager.getCurrentItem())
						.getUrl_type().equals("web")) {
					intent.putExtra("bannerlistbean",
							banerlistbak.get(myview_pager.getCurrentItem()));
					intent.setClass(getActivity(), WebActivity.class);
					startActivity(intent);
				} else if (banerlistbak.get(myview_pager.getCurrentItem())
						.getUrl_type().equals("in_app")) {
					if (!saveUtils.getBoolSP(KeepingData.LOGINED)) {
						intent.setClass(getActivity(), LoginActivity.class);
					} else {
						Gson gson = new Gson();
						InappUrlbean inappurlbean = gson.fromJson(banerlistbak
								.get(myview_pager.getCurrentItem()).getUrl(),
								InappUrlbean.class);
						intent.setClass(getActivity(), Kclassdata
								.getRechageclsss(inappurlbean.getKlass()));
					}
					startActivity(intent);
				}
			}
		});
		initView();
		handler.sendEmptyMessageDelayed(0, 3000);
		return view;
	}

	private void startanim() {
		tosmallanimation = (Animation) AnimationUtils.loadAnimation(
				getActivity(), R.anim.main_btn_scal_big);
		main_order_btn.startAnimation(tosmallanimation);
	}

	public static TextView getloctionview() {
		return loction_text;
	}

	private void get_func_button_list() {
		parms.clear();
		parms.put("width",
				String.valueOf(DensityUtil.getWidthInPx(getActivity())));
		parms.put("height",
				String.valueOf(DensityUtil.getHeightInPx(getActivity())));
		if (saveUtils.getStrSP(KeepingData.User_City_Id) != null) {
			parms.put("city_id", saveUtils.getStrSP(KeepingData.User_City_Id));
		} else {
			parms.put("city_id", "1");
		}
		((MainActivity) getActivity()).getdate(parms,
				Common.GET_FUNC_BUTTON_LIST, handler, GETFUNCTIONBTNSUCCED,
				GETFUNCTIONBTNFAILD, false, true, false);
	}

	private void get_banner_list() {
		parms.clear();
		parms.put("width",
				String.valueOf(DensityUtil.getWidthInPx(getActivity())));
		parms.put("height",
				String.valueOf(DensityUtil.getHeightInPx(getActivity())));
		if (saveUtils.getStrSP(KeepingData.User_City_Id) != null) {
			parms.put("city_id", saveUtils.getStrSP(KeepingData.User_City_Id));
		} else {
			parms.put("city_id", "1");
		}
		((MainActivity) getActivity()).getdate(parms, Common.GET_BANNER_LIST,
				handler, GETBANNERSUCCED, GETBANNERFAILD, true, true, false);

	}

	private void initView() {
		banerlistbak = new ArrayList<Bannerlistbean>();
		funditonlist = new ArrayList<Bannerlistbean>();
		saveUtils = new SaveUtils(this.getActivity());
		parms = new HashMap<String, String>();
		get_banner_list();
		title = new TitleAdapter(banerlistbak);
		myview_pager.setAdapter(title);
		adapter = new Myfuncadpter(getActivity(), funditonlist);
		main_grid.setAdapter(adapter);
		get_func_button_list();
		Animation toleftanim = (Animation) AnimationUtils.loadAnimation(
				getActivity(), R.anim.toleft_translaneannim);
		final Animation torightanim = (Animation) AnimationUtils.loadAnimation(
				getActivity(), R.anim.toright_translateanim);
		final Animation torightanim1 = (Animation) AnimationUtils
				.loadAnimation(getActivity(), R.anim.toleft_translation);
		final Animation toleftanim1 = (Animation) AnimationUtils.loadAnimation(
				getActivity(), R.anim.long_short_anim);
		AnimationListener animationListener = new AnimationListener() {
			@Override
			public void onAnimationStart(Animation animation) {
			}

			@Override
			public void onAnimationRepeat(Animation animation) {

			}

			@Override
			public void onAnimationEnd(Animation animation) {
				Animorder++;
				switch (Animorder) {
				case 1:
					anim_womencloth.startAnimation(torightanim);
					break;
				case 2:
					anim_clothsmall.startAnimation(torightanim1);
					break;
				case 3:
					anim_sleeveshort.startAnimation(toleftanim1);
					break;
				default:
					break;
				}
			}
		};
		anim_trousers.setVisibility(View.VISIBLE);
		anim_womencloth.setVisibility(View.VISIBLE);
		anim_clothsmall.setVisibility(View.VISIBLE);
		anim_sleeveshort.setVisibility(View.VISIBLE);
		anim_trousers.startAnimation(toleftanim);
		toleftanim.setAnimationListener(animationListener);
		torightanim.setAnimationListener(animationListener);
		torightanim1.setAnimationListener(animationListener);
		toleftanim1.setAnimationListener(animationListener);
		main_order_btn.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				startanim();
				tosmallanimation.setAnimationListener(new AnimationListener() {

					@Override
					public void onAnimationStart(Animation animation) {
					}

					@Override
					public void onAnimationRepeat(Animation animation) {
					}

					@Override
					public void onAnimationEnd(Animation animation) {

						if (!saveUtils.getBoolSP(KeepingData.LOGINED)) {
							startActivity(new Intent(getActivity(),
									LoginActivity.class));
							return;
						}
						;
						Intent intent = new Intent(getActivity(),
								PlaceorderActivity.class);
						intent.putExtra("from", "fromMain");
						intent.putExtra(KeepingData.ADDRESS_DATA, address);
						startActivity(intent);
					}
				});

			}
		});
		loction_text.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(getActivity(),
						CityListActivity.class);
				startActivityForResult(intent, getActivity().RESULT_FIRST_USER);
			}
		});
	}

	@Override
	public void setUserVisibleHint(boolean isVisibleToUser) {
		super.setUserVisibleHint(isVisibleToUser);
		if (isVisibleToUser) {
			is_Loop_Flag = true;
			handler.sendEmptyMessageDelayed(0, 3000);
			if (NetUtil.getNetworkState(getActivity())) {
				if ((funditonlist != null) && !RequstFlag) {
					Timer timer = new Timer();
					timer.schedule(new TimerTask() {
						@Override
						public void run() {
							getActivity().runOnUiThread(new Runnable() {
								@Override
								public void run() {
									get_banner_list();
									get_func_button_list();
								}
							});
						}
					}, 500);
				}
			}
		} else {
			is_Loop_Flag = false;
		}
	}

	private int[] getImageResIDs() {
		return new int[] { R.drawable.splash_dot_default,
				R.drawable.splash_dot_current };
	}

	private class TitleAdapter extends PagerAdapter {

		private ArrayList<Bannerlistbean> mbannerlist;

		public TitleAdapter(ArrayList<Bannerlistbean> bannerlist) {
			super();
			mbannerlist = bannerlist;
		}

		@Override
		public int getCount() {
			int size = mbannerlist.size() == 0 ? 2 : mbannerlist.size();
			// if (mbannerlist.size() > 0) {
			// return size;
			// } else {
			// return 2;
			// }
			return 3;
		}

		@Override
		public boolean isViewFromObject(View arg0, Object arg1) {
			return arg0 == arg1;
		}

		@Override
		public void destroyItem(ViewGroup container, int position, Object object) {
			((ViewPager) container).removeView((View) object);
		}

		@Override
		public Object instantiateItem(ViewGroup container, final int position) {
			View view = View
					.inflate(getActivity(), R.layout.bander_title, null);
			imageView_title = (ImageView) view
					.findViewById(R.id.iv_bander_title);
			imageView_title.setScaleType(ScaleType.CENTER_CROP);
			imageView_title.setImageResource(R.drawable.banner_default);
			if (mbannerlist.size() == 0) {
				container.addView(view, 0);
				return view;
			} else {
				BitmapUtils utils = new BitmapUtils(getActivity());
				utils.display(imageView_title, mbannerlist.get(position)
						.getImage_url());
				container.addView(view, position);
				return view;
			}
		}
	}

	/** 动态添加轮播图小圆点 **/
	protected void addBannerPoint() {
		for (int i = 0; i < banerlistbak.size(); i++) {
			point = new ImageView(getActivity());
			point.setBackgroundResource(R.drawable.splash_dot_current);

			LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
					LinearLayout.LayoutParams.WRAP_CONTENT,
					LinearLayout.LayoutParams.WRAP_CONTENT);
			params.gravity = Gravity.CENTER;
			point.setLayoutParams(params);
			point.setVisibility(View.VISIBLE);
			if (i == 0) {
				point.setEnabled(true);
			} else {
				point.setEnabled(false);
			}
			pager_bottom.addView(point);
		}
	}

	/** 解析banner结果方法 **/
	protected void paserbaner(String json, ArrayList<Bannerlistbean> bannerlist) {
		JSONArray jsonArray;
		bannerlist.clear();
		try {
			jsonArray = new JSONArray(json);
			for (int i = 0; i < jsonArray.length(); i++) {
				str = (JSONObject) jsonArray.opt(i);
				Bannerlistbean bannerlistbean = new Bannerlistbean();
				bannerlistbean.setImage_url(str.getString("image_url"));
				bannerlistbean.setUrl_type(str.getString("url_type"));
				bannerlistbean.setUrl(str.getString("url"));
				bannerlistbean.setTitle(str.getString("title"));
				if (str.getString("title").equals("按袋计费")) {
					saveUtils.saveStrSP(KeepingData.An_Dai_Ji_Fei_Url,
							str.getString("url"));
				} else if (str.getString("title").equals("按件计费")) {
					saveUtils.saveStrSP(KeepingData.An_Jian_Ji_Fei_Url,
							str.getString("url"));
				}
				bannerlist.add(bannerlistbean);
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}
	}

	/** 回调用户选中城市结果方法 **/
	@Override
	public void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		if (saveUtils.getStrSP(KeepingData.User_City) != "") {
			loction_text.setText(saveUtils.getStrSP(KeepingData.User_City));
			get_banner_list();
			get_func_button_list();
		}
	}

	/** dp px 转换工具方法 **/
	private int dp2px(int dp) {
		return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp,
				getResources().getDisplayMetrics());
	}
}

  布局就省略了。

时间: 2024-10-23 09:30:10

Android viewpager 嵌套 viewpager滑动 点击事件冲突解决方案的相关文章

Android Listview中Button按钮点击事件冲突解决办法

  今天做项目时,ListView中含有了Button组件,心里一早就知道肯定会有冲突,因为以前就遇到过,并解决过,可惜当时没有记录下来. 今天在做的时候,继续被这个问题郁闷了一把,后来解决后,赶紧来记录下,以便日后参考.      首先,其实Listview中Button按钮点击事件冲突这种问题压根就不是太大的问题,因为我们完全可以将一个TextView的Backgroud设置成一个selector,也可以将一个TextView设计成一个按钮的样子,这样就可以绕过ListView和Button

Android ScrollView嵌套横向滑动控件时冲突问题

前言:今天在开发的时候遇到这样的问题,最外层是ScrollView,里面嵌套了一个横向滑动的日历控件,在滑动日历的时候很卡顿.看到这种问题,自然而然的就会想到scrollview和其他可滑动控件的冲突问题. 解决思路 用户的左右滑动操作被最外层的scrollView控件处理掉了,所以只要让scrollview对左右滑动事件不监听,让其子控件处理左右滑动事件 .重写scrollview的onInterceptTouchEvent方法,当上下滑动时不处理即可. 代码如下 public void se

viewpager嵌套viewpager父vp禁止左右滑动

问题描述 viewpager嵌套viewpager父vp禁止左右滑动 viewpager嵌套viewpager如何让父viewpager禁止左右滑动,子viewpager正常滑动 解决方案 问题是,,,父viewpager是禁止滑动的,但是子scroll滑动时偶尔会滑动父viewpager... 解决方案二: ViewPager禁止左右滑动禁止ViewPager左右滑动禁止ViewPager左右滑动

android li...-listview触摸事件和点击事件冲突怎么解决额

问题描述 listview触摸事件和点击事件冲突怎么解决额 比如我按住listviem的某项往下拖动,其实就是下拉刷新动作.但是松开手后onitemclicklistener事件就会响应了 怎么在拖动listview的时候让点击事件不想应呢 action move down 会响应click事件啊 解决方案 滑动时,你可以用一个变量记录当前处于滑动状态,这样在抬起时可以判断这个标记,不要触发点击了 解决方案二: 在ListView中的Text添加spannableString 点击事件与List

Android中捕捉menu按键点击事件的方法_Android

本文实例讲述了Android中捕捉menu按键点击事件的方法.分享给大家供大家参考.具体如下: @Override public boolean onCreateOptionsMenu(Menu menu) { /* * add()方法的四个参数,依次是: 1.组别,如果不分组的话就写Menu.NONE, * 2.Id,这个很重要,Android根据这个Id来确定不同的菜单 3.顺序,那个菜单现在在前面由这个参数的大小决定 * 4.文本,菜单的显示文本 */ menu.add(Menu.NONE

图片选择-Android中gridview中item点击事件及选中标记

问题描述 Android中gridview中item点击事件及选中标记 求大神帮忙,gridview中的item我加载了一个CheckBox我在适配器中设置了CheckBox的点击事件,gridview的item 点击事件就不能得到触发,现在我想实现的是点击某一个item,对这个item进行标记,再次点击就消除标记!就像QQ上的选中图片,然后进行预览和发送一样的效果,求大神解答 解决方案 将布局文件中的checkbox的属性设置一下,android:focusable=""false&

android 如何给webview添加点击事件

问题描述 android 如何给webview添加点击事件 我使用了 onclicklistener没有效果,怎么给它添加点击事件呢? 解决方案 点击事件不是有不同方式吗,试试在布局文件相应组件下添加onclick属性,Java文件里添加相同名称的函数,形参(View v)这种方法试试 解决方案二: webview是浏览网页的,如果设置重载url不更换浏览器的话,是可以当成一个浏览器使用的,你点击webview肯定会把焦点转移到网页内容上,因此它默认不可点击,不过你可以看看它能不能ontouch

Android recycleView的应用和点击事件实例详解

Android recycleView的应用和点击事件 效果图: 长按是删除: 下面代码: MainActivity 类 public class MainActivity extends AppCompatActivity { RecyclerView rv; List<String> mList = new ArrayList<>(); @Override protected void onCreate(Bundle savedInstanceState) { super.on

listview-ListView的Item中的webView控件与Item点击事件冲突?

问题描述 ListView的Item中的webView控件与Item点击事件冲突? 各位大神大侠们好! 我编写了一个自定义item的ListView,自定义的ListView Item里有两个控件,一个是checkBox, 另一个是webView. 一开始ListView的点击事件完全没反应,在网上搜索了答案解决了,checkBox与ListView 点击冲突,点击checkBox区域可以响应ListView的点击事件.但是点击webView 区域不能响应ListView的点击事件. 以下是我I