ListView setItemsCanFocus - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for ListView setItemsCanFocus method.

This code example shows how to use the following methods:setChoiceMode, setItemChecked, setAdapter, setItemsCanFocus, setOnItemClickListener
     * Populates the UI ListView with the given list of items and selects an item 
     * based on {@code mSelectedItemIndex} member variable. 
     */ 
    private final void populateUIAccountList(String[] listItems) {
      ListView list = (ListView) findViewById(android.R.id.list);
      list.setAdapter(new ArrayAdapter<String>(this,
              android.R.layout.simple_list_item_single_choice, listItems));
      list.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
      list.setItemsCanFocus(false);
      list.setOnItemClickListener(
              new AdapterView.OnItemClickListener() {
                  @Override 
                  public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
                      mSelectedItemIndex = position;
                      mOkButton.setEnabled(true);
                  } 
              }); 
      if (mSelectedItemIndex != SELECTED_ITEM_NONE) {
          list.setItemChecked(mSelectedItemIndex, true);
          if (Log.isLoggable(TAG, Log.VERBOSE)) {

7
CodeRank
This code example shows how to use the following methods:setDescendantFocusability, setFastScrollEnabled, setSmoothScrollbarEnabled, setTranscriptMode, setAdapter
This code example shows how to use the following methods:setChoiceMode, setItemsCanFocus
        getSupportMenuInflater().inflate(R.menu.tutorial_standard, menu);
        return true; 
    } 
 
    private void setupActionBar() { 
        mList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
        mList.setItemsCanFocus(false);
    } 
 
    @Override 
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
 
        String message = String.format("%s %s", (position + 1), this.getString(R.string.clicked));
 
        Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
    } 
} 
6
CodeRank

Related ListView setItemsCanFocus Questions & Answers:

setItemsCanFocus Method Overview
Indicates that the views created by the ListAdapter can contain focusable items.
See Code Examples for other Android ListView Methods: