Java Code Examples for android.widget.ListView#setLongClickable()

The following examples show how to use android.widget.ListView#setLongClickable() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.measurementManager = new MeasurementManager(getApplicationContext());
    setContentView(R.layout.activity_history);
    initDrawer();

    // Fill the listview
    historyListAdapter = new InformationHistoryAdapter(measurementManager, this);
    infohistory = (ListView)findViewById(R.id.listiew_history);
    infohistory.setMultiChoiceModeListener(new HistoryMultiChoiceListener(this));
    infohistory.setAdapter(historyListAdapter);
    infohistory.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    infohistory.setLongClickable(true);
    infohistory.setOnItemClickListener(new HistoryItemListener(this));
}
 
Example 2
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    // View management
    mDualPane = getResources().getBoolean(R.bool.use_dual_panes);


    // Modify list view
    ListView lv = getListView();
    lv.setVerticalFadingEdgeEnabled(true);
    // lv.setCacheColorHint(android.R.color.transparent);
    if (mDualPane) {
        lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        lv.setItemsCanFocus(false);
    } else {
        lv.setChoiceMode(ListView.CHOICE_MODE_NONE);
        lv.setItemsCanFocus(true);
    }
    
    // Map long press
    lv.setLongClickable(true);
    lv.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> ad, View v, int pos, long id) {
            turnOnActionMode();
            getListView().setItemChecked(pos, true);
            mMode.invalidate();
            return true;
        }
    });
}
 
Example 3
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_favorites, container, false);
    mListView = (ListView) rootView.findViewById(android.R.id.list);
    mListView.setEmptyView(rootView.findViewById(android.R.id.empty));
    mListView.setLongClickable(true);
    mListView.setOnItemLongClickListener(this);
    return rootView;
}