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

The following are Jave code examples for showing how to use isItemChecked() 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: CSipSimple   File: CallLogListFragment.java   View Source Code Vote up 10 votes
private void actionModeDialpad() {
    
    ListView lv = getListView();

    for(int i = 0; i < lv.getCount(); i++) {
        if(lv.isItemChecked(i)) {
            mAdapter.getItem(i);
            String number = mAdapter.getCallRemoteAtPostion(i);
            if(!TextUtils.isEmpty(number)) {
                Intent it = new Intent(Intent.ACTION_DIAL);
                it.setData(SipUri.forgeSipUri(SipManager.PROTOCOL_SIP, number));
                startActivity(it);
            }
            break;
        }
    }
    mMode.invalidate();
    
}
 
Example 2
Project: CSipSimple   File: CallLogListFragment.java   View Source Code Vote up 7 votes
private void actionModeDelete() {
    ListView lv = getListView();
    
    ArrayList<Long> checkedIds = new ArrayList<Long>();
    
    for(int i = 0; i < lv.getCount(); i++) {
        if(lv.isItemChecked(i)) {
            long[] selectedIds = mAdapter.getCallIdsAtPosition(i);
            
            for(long id : selectedIds) {
                checkedIds.add(id);
            }
            
        }
    }
    if(checkedIds.size() > 0) {
        String strCheckedIds = TextUtils.join(", ", checkedIds);
        Log.d(THIS_FILE, "Checked positions ("+ strCheckedIds +")");
        getActivity().getContentResolver().delete(SipManager.CALLLOG_URI, Calls._ID + " IN ("+strCheckedIds+")", null);
        mMode.finish();
    }
}
 
Example 3
Project: ultrasonic   File: SelectAlbumActivity.java   View Source Code Vote up 6 votes
private static List<MusicDirectory.Entry> getSelectedSongs(ListView albumListView)
{
	List<MusicDirectory.Entry> songs = new ArrayList<MusicDirectory.Entry>(10);

	if (albumListView != null)
	{
		int count = albumListView.getCount();
		for (int i = 0; i < count; i++)
		{
			if (albumListView.isItemChecked(i))
			{
				songs.add((MusicDirectory.Entry) albumListView.getItemAtPosition(i));
			}
		}
	}

	return songs;
}
 
Example 4
Project: ultrasonic   File: BookmarkActivity.java   View Source Code Vote up 6 votes
private static List<MusicDirectory.Entry> getSelectedSongs(ListView albumListView)
{
	List<MusicDirectory.Entry> songs = new ArrayList<MusicDirectory.Entry>(10);

	if (albumListView != null)
	{
		int count = albumListView.getCount();
		for (int i = 0; i < count; i++)
		{
			if (albumListView.isItemChecked(i))
			{
				songs.add((MusicDirectory.Entry) albumListView.getItemAtPosition(i));
			}
		}
	}

	return songs;
}
 
Example 5
Project: CSipSimple   File: CallLogListFragment.java   View Source Code Vote up 5 votes
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
    Log.d(THIS_FILE, "onPrepareActionMode");
    ListView lv = getListView();
    int nbrCheckedItem = 0;

    for (int i = 0; i < lv.getCount(); i++) {
        if (lv.isItemChecked(i)) {
            nbrCheckedItem++;
        }
    }
    menu.findItem(R.id.delete).setVisible(nbrCheckedItem > 0);
    menu.findItem(R.id.dialpad).setVisible(nbrCheckedItem == 1);
    return false;
}