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

The following examples show how to use android.widget.ListView#setFocusableInTouchMode() . 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 check out the related API usage on the sidebar.
Example 1
protected void initView() {
    mHandler = new Handler();

    mScrollView = (XScrollView) findViewById(R.id.scroll_view);
    mScrollView.setPullRefreshEnable(true);
    mScrollView.setPullLoadEnable(true);
    mScrollView.setAutoLoadEnable(true);
    mScrollView.setIXScrollViewListener(this);
    mScrollView.setRefreshTime(getTime());

    View content = LayoutInflater.from(this).inflate(R.layout.vw_scroll_view_content, null);

    if (null != content) {
        mListView = (ListView) content.findViewById(R.id.content_list);
        mListView.setFocusable(false);
        mListView.setFocusableInTouchMode(false);

        mAdapter = new ArrayAdapter<String>(this, R.layout.vw_list_item, mItems);
        mListView.setAdapter(mAdapter);
        measureHeight();
    }

    mScrollView.setView(content);
}
 
Example 2
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    List<String> fragmentTitles = mFragmentListSupporter.getListTitles();

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_activated_1,
            fragmentTitles.toArray(new String[fragmentTitles.size()]));

    int color = Compat.getColor(getActivity(), R.color.formcolor);
    int[] colors = {0, color, 0};
    ListView listView = getListView();
    listView.setDivider(new GradientDrawable(Orientation.RIGHT_LEFT, colors));
    listView.setDividerHeight(2);

    listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    listView.setFocusableInTouchMode(true);
    StateListDrawable selector = new StateListDrawable();
    selector.addState(new int[]{-android.R.attr.state_pressed}, new ColorDrawable(Compat.getColor(getContext(), R.color.main_selection)));
    listView.setSelector(selector);

    setListAdapter(adapter);

    if (fragmentTitles.size() > 0)
        listView.setItemChecked(0, true);
}