private void populateList() { ListView lv = getListView(); lv.setTextFilterEnabled(true); lv.setCacheColorHint(0); ((TouchInterceptor) lv).setDragListener(mDragListener); ((TouchInterceptor) lv).setDropListener(mDropListener); lv.setDivider(null); mArray = Page.getAllPages(getContext()); mAdapter = new PageAdapter(getContext(), mArray); setListAdapter(mAdapter); lv.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> av, View v, int position, long id) { if (!"settings".equals(mArray.get(position).getKey())) { boolean isEnabled = CalculatorSettings.isPageEnabled(getContext(), mArray.get(position)); CalculatorSettings.setPageEnabled(getContext(), mArray.get(position), !isEnabled); mAdapter.notifyDataSetChanged(); } } }); }
@Override public final boolean onTouchEvent(final MotionEvent event) { if (mTouchInterceptor != null) { final boolean ret = mTouchInterceptor.onTouchEvent(this, event); if (ret) return true; } return super.onTouchEvent(event); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); mListView = new TouchInterceptor(getContext()); mListView.setId(android.R.id.list); return mListView; }