Example usage for android.widget ListView setItemsCanFocus

List of usage examples for android.widget ListView setItemsCanFocus

Introduction

In this page you can find the example usage for android.widget ListView setItemsCanFocus.

Prototype

public void setItemsCanFocus(boolean itemsCanFocus) 

Source Link

Document

Indicates that the views created by the ListAdapter can contain focusable items.

Usage

From source file:org.totschnig.myexpenses.fragment.PartiesList.java

@Override
@SuppressLint("InlinedApi")
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.parties_list, container, false);

    final ListView lv = (ListView) v.findViewById(R.id.list);
    lv.setItemsCanFocus(false);
    //((TextView) findViewById(android.R.id.empty)).setText(R.string.no_parties);
    // Create an array to specify the fields we want to display in the list
    String[] from = new String[] { DatabaseConstants.KEY_PAYEE_NAME };

    // and an array of the fields we want to bind those fields to 
    int[] to = new int[] { android.R.id.text1 };

    // Now create a simple cursor adapter and set it to display
    mAdapter = new SimpleCursorAdapter(getActivity(),
            Build.VERSION.SDK_INT >= 11 ? android.R.layout.simple_list_item_activated_1
                    : android.R.layout.simple_list_item_1,
            null, from, to, 0);/*from ww  w .  ja  v  a2  s .c  om*/

    getLoaderManager().initLoader(0, null, this);
    lv.setAdapter(mAdapter);
    lv.setEmptyView(v.findViewById(R.id.empty));
    registerForContextualActionBar(lv);
    return v;
}

From source file:com.pindroid.fragment.BrowseNotesFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    setHasOptionsMenu(true);//from  w w w .j  a v  a2s .  com

    mAdapter = new SimpleCursorAdapter(this.getActivity(), R.layout.note_view, null,
            new String[] { Note.Title }, new int[] { R.id.note_title }, 0);

    setListAdapter(mAdapter);

    getLoaderManager().initLoader(0, null, this);

    final ListView lv = getListView();
    lv.setTextFilterEnabled(true);
    lv.setFastScrollEnabled(true);

    lv.setItemsCanFocus(false);
    lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

    lv.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            final Cursor c = (Cursor) lv.getItemAtPosition(position);
            Note n = NoteManager.CursorToNote(c);

            viewNote(n);
        }
    });

    getActivity().setTitle(getString(R.string.browse_my_notes_title));
}

From source file:com.pindroid.fragment.SelectTagsFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    setHasOptionsMenu(true);/*from ww w .  j a v a 2 s.com*/

    mAdapter = new SimpleCursorAdapter(this.getActivity(), android.R.layout.simple_list_item_multiple_choice,
            null, new String[] { Tag.Name }, new int[] { android.R.id.text1 }, 0);

    setListAdapter(mAdapter);

    getLoaderManager().initLoader(0, null, this);

    ListView lv = getListView();
    lv.setTextFilterEnabled(true);
    lv.setFastScrollEnabled(true);

    lv.setItemsCanFocus(false);
    lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

}

From source file:com.pindroid.fragment.BrowseTagsFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mAdapter = new SimpleCursorAdapter(this.getActivity(), R.layout.tag_view, null,
            new String[] { Tag.Name, Tag.Count }, new int[] { R.id.tag_name, R.id.tag_count }, 0);

    setListAdapter(mAdapter);//w  w  w.  j  a v a  2s . c o  m

    getLoaderManager().initLoader(0, null, this);

    ListView lv = getListView();
    lv.setTextFilterEnabled(true);
    lv.setFastScrollEnabled(true);
    lv.setOnItemClickListener(clickListener);

    lv.setItemsCanFocus(false);
    lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
}

From source file:com.deliciousdroid.fragment.BrowseBundlesFragment.java

@Override
public void onActivityCreated(android.os.Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    setHasOptionsMenu(true);/*from  www.j  a va2 s  .  c  o  m*/

    mAdapter = new SimpleCursorAdapter(this.getActivity(), R.layout.bundle_view, null,
            new String[] { Bundle.Name, Bundle.Tags }, new int[] { R.id.bundle_name, R.id.bundle_tags }, 0);

    setListAdapter(mAdapter);

    getLoaderManager().initLoader(0, null, this);

    ListView lv = getListView();
    lv.setTextFilterEnabled(true);
    lv.setFastScrollEnabled(true);
    lv.setOnItemClickListener(clickListener);

    lv.setItemsCanFocus(false);
    lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
}

From source file:com.deliciousdroid.fragment.BrowseTagsFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    setHasOptionsMenu(true);/* www  .j av a 2s.c  o m*/

    mAdapter = new SimpleCursorAdapter(this.getActivity(), R.layout.tag_view, null,
            new String[] { Tag.Name, Tag.Count }, new int[] { R.id.tag_name, R.id.tag_count }, 0);

    setListAdapter(mAdapter);

    getLoaderManager().initLoader(0, null, this);

    ListView lv = getListView();
    lv.setTextFilterEnabled(true);
    lv.setFastScrollEnabled(true);
    lv.setOnItemClickListener(clickListener);

    lv.setItemsCanFocus(false);
    lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
}

From source file:com.aboveware.sms.ui.MessageSearchResultActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    String searchStringParameter = getIntent().getStringExtra(SearchManager.QUERY);
    searchString = searchStringParameter != null ? searchStringParameter.trim() : "";
    setContentView(R.layout.search_activity);

    final ListView listView = getListView();
    listView.setItemsCanFocus(true);
    listView.setFocusable(true);/*  www  . j a  v  a 2s.  co m*/
    listView.setClickable(true);

    // Create an empty adapter we will use to display the loaded data.
    suggestionAdapter = new SuggestionListAdapter(this, null);
    setListAdapter(suggestionAdapter);
    getSupportLoaderManager().initLoader(0, null, this);

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
}

From source file:com.abcvoipsip.ui.favorites.FavListFragment.java

@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 {// w  ww  .  ja  v  a2  s  .c  o  m
        lv.setChoiceMode(ListView.CHOICE_MODE_NONE);
        lv.setItemsCanFocus(true);
    }

    // Start out with a progress indicator.
    // setListShown(false);

}

From source file:cat.wuyingren.rorhelper.fragments.GameListFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    dataSource = new GameDataSource(getActivity());
    dataSource.open();/* ww  w  .  jav a2s .  co m*/

    values = dataSource.getAllGames();

    adapter = new MultipleRowAdapter(getActivity(), values);

    setListAdapter(adapter);

    final ListView listView = getListView();
    listView.setItemsCanFocus(false);
    listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    listView.setMultiChoiceModeListener(new ListView.MultiChoiceModeListener() {

        @Override
        public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
            // Here you can do something when items are selected/de-selected,
            // such as update the title in the CAB
            //mode.setTag();
            int selectionColor = getResources().getColor(R.color.colorPrimary);
            Log.w("TAG", "onItemCheckedStateChanged() " + checked + " " + position);
            mode.setSubtitle(listView.getCheckedItemCount() + " selected");
            if (checked) {
                listView.getChildAt(position).setBackgroundColor(selectionColor);
            } else {
                listView.getChildAt(position)
                        .setBackgroundColor(getResources().getColor(android.R.color.transparent));
            }
        }

        @Override
        public boolean onCreateActionMode(android.view.ActionMode mode, Menu menu) {
            // Inflate the menu for the CAB

            Log.w("TAG", "onCreateActionMode");
            MenuInflater inflater = mode.getMenuInflater();
            inflater.inflate(R.menu.menu_context, menu);
            mode.setTitle(getString(R.string.action_choose));
            return true;
        }

        @Override
        public boolean onPrepareActionMode(android.view.ActionMode mode, Menu menu) {
            // Here you can perform updates to the CAB due to
            // an invalidate() request
            return false;
        }

        @Override
        public boolean onActionItemClicked(android.view.ActionMode mode, MenuItem item) {
            // Respond to clicks on the actions in the CAB

            switch (item.getItemId()) {
            case R.id.action_delete:
                deleteItems(listView.getCheckedItemPositions());
                mode.finish();
                return true;
            default:
                return false;
            }
        }

        @Override
        public void onDestroyActionMode(android.view.ActionMode mode) {
            // Here you can make any necessary updates to the activity when
            // the CAB is removed. By default, selected items are deselected/unchecked.

            SparseBooleanArray checked = listView.getCheckedItemPositions();
            for (int i = 0; i < listView.getAdapter().getCount(); i++) {
                if (checked.get(i)) {
                    listView.getChildAt(i)
                            .setBackgroundColor(getResources().getColor(android.R.color.transparent));
                }
            }
        }

    });
    // dataSource.close();
}

From source file:com.androidquery.simplefeed.activity.FriendsActivity.java

private void initView() {

    friends = new FriendsAdapter();

    aq.id(R.id.list);// w w w.  j a va2  s  .co  m

    aq.adapter(friends).scrolledBottom(this, "scrolledBottom").itemClicked(this, "itemClicked");

    ListView lv = aq.getListView();
    lv.setItemsCanFocus(false);
    lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

    ajaxFriends(0);

    aq.id(R.id.edit_input).textChanged(this, "searchChanged");

    if (selectable) {
        aq.id(R.id.done_box).visible();
        aq.id(R.id.button_done).clicked(this, "doneClicked");
    }
}