Java Code Examples for android.widget.ListView.setOnTouchListener()

The following are Jave code examples for showing how to use setOnTouchListener() of the android.widget.ListView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: pracler   File: PlayListActivity.java   View Source Code Vote up 8 votes
public void viewInitialize()
{
    mainListView = (ListView) findViewById(R.id.listview);
    scrollview = (NestedScrollView) findViewById(R.id.scrollview);
    mainListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            Log.e("PlayListFragment", i+"/"+l);
            global.playMusic(Integer.parseInt(playList.get(i)));
        }
    });
    mainListView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event)
        {
            scrollview.requestDisallowInterceptTouchEvent(true);
            return false;
        }
    });

}
 
Example 2
Project: GitHub   File: ProfilesActivity.java   View Source Code Vote up 6 votes
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PrefStore.setLocale(this);
    setContentView(R.layout.activity_profiles);

    // ListView Adapter
    listView = (ListView) findViewById(R.id.profilesView);
    adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_single_choice, listItems);
    listView.setAdapter(adapter);

    // Initialize the Gesture Detector
    listView.setOnTouchListener(this);
    gd = new GestureDetector(this,
            new GestureDetector.SimpleOnGestureListener() {
                @Override
                public boolean onDoubleTap(MotionEvent e) {
                    finish();
                    return false;
                }
            });
}
 
Example 3
Project: GravityBox   File: QsDetailItemsList.java   View Source Code Vote up 6 votes
private QsDetailItemsList(LinearLayout view) {
    mView = view;

    mListView = (ListView) mView.findViewById(android.R.id.list);
    mListView.setOnTouchListener(new OnTouchListener() {
        // Setting on Touch Listener for handling the touch inside ScrollView
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // Disallow the touch request for parent scroll on touch of child view
            v.getParent().requestDisallowInterceptTouchEvent(true);
            return false;
        }
    });
    mEmpty = mView.findViewById(android.R.id.empty);
    mEmpty.setVisibility(View.GONE);
    mEmptyText = (TextView) mEmpty.findViewById(android.R.id.title);
    mEmptyIcon = (ImageView) mEmpty.findViewById(android.R.id.icon);
    mListView.setEmptyView(mEmpty);
}
 
Example 4
Project: godlibrary   File: ListViewRefresh.java   View Source Code Vote up 4 votes
public ListViewRefresh(ListView listView) {
    this.listView = listView;
    listView.setOnTouchListener(this);

}
 
Example 5
Project: godlibrary   File: ListViewRefresh.java   View Source Code Vote up 4 votes
public ListViewRefresh(ListView listView) {
    this.listView = listView;
    listView.setOnTouchListener(this);

}
 
Example 6
Project: TrackPlan-app   File: MainrearrActivity.java   View Source Code Vote up 4 votes
public void rearranging() {

        mListView = (ListView) findViewById(R.id.listrearr);


        mAdapter = new MyArrayAdapter(this, R.layout.row_string);



            mListView.setAdapter(mAdapter);



        mListView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent event) {
                if (!mSortable) {
                    return false;
                }
                switch (event.getAction()) {
                    case MotionEvent.ACTION_DOWN: {
                        break;
                    }
                    case MotionEvent.ACTION_MOVE: {

                        int position = mListView.pointToPosition((int) event.getX(), (int) event.getY());
                        if (position < 0) {
                            break;
                        }

                        if (position != mPosition) {
                            mPosition = position;
                            mAdapter.remove(mDragString);
                            mAdapter.insert(mDragString, mPosition);
                        }
                        return true;
                    }
                    case MotionEvent.ACTION_UP:
                    case MotionEvent.ACTION_CANCEL:
                    case MotionEvent.ACTION_OUTSIDE: {
                        stopDrag();
                        return true;
                    }
                }
                return false;
            }
        });



        DatabaseHandler db1 = new DatabaseHandler(this);
        List<Contact> contacts1 = db1.getAllContacts();


    }
 
Example 7
Project: Android-Practice   File: MainActivity.java   View Source Code Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    ArrayList<String> arData = new ArrayList<String>();
    mAdapter = new ArrayAdapter<String>(this, R.layout.support_simple_spinner_dropdown_item, arData);
    ListView list = (ListView)findViewById(R.id.logList);
    mAdapter.add("ssss");
    list.setAdapter(mAdapter);

    try {
        FileInputStream fis = openFileInput("MousePos.txt");
        FileChannel inChannel = fis.getChannel();

        final int s = fis.available();
        ByteBuffer buff = ByteBuffer.allocate((int)fis.available());
        buff.clear();

        inChannel.read(buff);

        buff.rewind();

        final int posSize = s/4;
        float[] pos = new float[posSize];
        buff.asFloatBuffer().get(pos);

        inChannel.close();

        for (int i=0; i < posSize; i+=2)
        {
            mAdapter.add("" + pos[i] + ", " + pos[i+1]);
        }

        fis.close();
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }

    list.setOnTouchListener(this);
}