我需要的是检测项目的正确滑动并显示一些活动.
我做了上一个.调查,但似乎没有明显的正确解决方案.
请帮我.
我做了上一个.调查,但似乎没有明显的正确解决方案.
请帮我.
我的代码如下.
public class FragmentTwo extends ListFragment { public FragmentTwo() { } @Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_fragment_two,container,false); return view; } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); ListView listView = getListView(); listView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v,MotionEvent event) { if(event.getAction() == MotionEvent.ACTION_UP){ Toast.makeText(getContext(),"ACTION_UP",Toast.LENGTH_SHORT).show(); return true; } if(event.getAction() == MotionEvent.ACTION_DOWN){ Toast.makeText(getContext(),"ACTION_DOWN",Toast.LENGTH_SHORT).show(); return true; } if(event.getAction() == MotionEvent.ACTION_MOVE){ Toast.makeText(getContext(),"ACTION_MOVE",Toast.LENGTH_SHORT).show(); return true; } return false; } }); new FetchTransportData().execute(); } private class FetchTransportData extends AsyncTask<Void,Void,String> { @Override protected String doInBackground(Void... params) { // ... return result; } @Override protected void onPostExecute(String s) { super.onPostExecute(s); // ... CustomListAdapter adapter = new CustomListAdapter(getActivity(),unitViews); setListAdapter(adapter); } } }
解决方法
嗨,请按照以下链接,这是完美的工作,我已经尝试过,然后告诉你使用下面的链接,并按照它.
https://github.com/daimajia/AndroidSwipeLayout
希望这对你有用,节省你的时间.若工作正常,请关闭此问题并进行投票.