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
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setDescendantFocusability, setFastScrollEnabled, setSmoothScrollbarEnabled, setTranscriptMode, setAdapter
    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.v2andlib_fragment_list, null);
        ListView list = (ListView) view.findViewById(android.R.id.list);
        list.setDivider(null);
        list.setDescendantFocusability(ListView.FOCUS_BEFORE_DESCENDANTS);
        list.setFastScrollEnabled(false);
        list.setSmoothScrollbarEnabled(true);
        list.setItemsCanFocus(false);
        list.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
        mAdapter = new ArrayAdapter<String>(getActivity(), 
                android.R.layout.simple_dropdown_item_1line, new ArrayList<String>());
        list.setAdapter(mAdapter);
        return view;
    } 
 
 
    @Override 
    public void onClick(View v) {
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
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
Connect your IDE to all the code out there  Get Codota for Java

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: