当前位置: 首页>>代码示例>>Java>>正文


Java AbsListView.setOnItemLongClickListener方法代码示例

本文整理汇总了Java中android.widget.AbsListView.setOnItemLongClickListener方法的典型用法代码示例。如果您正苦于以下问题:Java AbsListView.setOnItemLongClickListener方法的具体用法?Java AbsListView.setOnItemLongClickListener怎么用?Java AbsListView.setOnItemLongClickListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.AbsListView的用法示例。


在下文中一共展示了AbsListView.setOnItemLongClickListener方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Controller

import android.widget.AbsListView; //导入方法依赖的package包/类
private Controller(AbsListView listView, AppCompatActivity activity,
        MultiChoiceModeListener listener) {
    mListView = listView;
    mActivity = activity;
    mListener = listener;
    mCallbacks = new Callbacks();
    // We set ourselves as the OnItemLongClickListener so we know when to start
    // an Action Mode
    listView.setOnItemLongClickListener(mCallbacks);
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:11,代码来源:MultiSelectionUtil.java

示例2: initList

import android.widget.AbsListView; //导入方法依赖的package包/类
/**
 * According the view mode, get the common object for the adapter.
 */
private void initList(final AbsListView list){
    list.setOnItemClickListener(this);
    list.setOnItemLongClickListener(this);
    // register for context menu.
    list.setOnCreateContextMenuListener(this);
    list.setOnScrollListener(this);
    list.setOnTouchListener(this);
    list.setChoiceMode(AbsListView.CHOICE_MODE_NONE);

    // Setup key listener to open extender with right key or L1 or R1 or "i"
    list.setOnKeyListener(new OnKeyListener() {
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            // All is done on action down because it also moves the focus, hence we can't wait for action up

             
             /*
              * Work around to handle issues on focus for android 4.1
              * 
              * Sometimes it is impossible to down with the pad.
              * what we know :
              * before going to the onkey method, list should have scrolled (except when and issue occured)
              * so, if we are going down, the last visible item has to be focused item +1 (focus is done after the function, when  return false)
              * if last visible item == selected item even if this isn't the last item of the list, then the list won't scroll anymore.
              * So we scroll it manually.
              * 
              */
            if (event.getAction() == KeyEvent.ACTION_DOWN && mArchosGridView instanceof ListView) {
                if (keyCode == KeyEvent.KEYCODE_DPAD_UP && mArchosGridView.getFirstVisiblePosition() == mArchosGridView.getSelectedItemPosition() && mArchosGridView.getSelectedItemPosition() > 0) {

                    mArchosGridView.setSelection(mArchosGridView.getSelectedItemPosition() - 1);
                    return true;


                }
                if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN && mArchosGridView.getLastVisiblePosition() == mArchosGridView.getSelectedItemPosition()
                        && mArchosGridView.getSelectedItemPosition() < mArchosGridView.getCount()) {
                    View v2 = mArchosGridView.getChildAt(mArchosGridView.getSelectedItemPosition() - mArchosGridView.getFirstVisiblePosition());
                    int scrollTo = (v2 == null) ? 0 : v2.getTop();
                    //we want the selected item to be at the end of the list
                    if (mArchosGridView instanceof ListView)
                        ((ListView) mArchosGridView).setSelectionFromTop(mArchosGridView.getSelectedItemPosition() + 1,
                                scrollTo);
                    return true;


                }

            }
            if (event.getAction() != KeyEvent.ACTION_DOWN)
                return false;
            if ((keyCode == KeyEvent.KEYCODE_BUTTON_L1) || (keyCode == KeyEvent.KEYCODE_BUTTON_R1) ||   // Nice for LUDO (even if an hidden feature)
                    (keyCode == KeyEvent.KEYCODE_I) ||                                                // Nice for any keyboard, LUDO included
                    ((keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) && (list instanceof GridView && (((GridView) list).getNumColumns() < 2) || list instanceof ListView)))// Right arrow is only used in list mode, can't be in grid mode
            {
                View selectedView = list.getSelectedView();
                if (selectedView != null) {
                    // Check that there is a visible "expander" in the selected list item
                    View expandView = selectedView.findViewById(R.id.expanded);
                    if ((expandView != null) && (expandView.getVisibility() == View.VISIBLE)) {
                        if (getFileType(list.getSelectedItemPosition()) == FileType.SmbDir)
                            return false;
                        expandView.requestFocus(); //test
                        displayInfo(list.getSelectedItemPosition());
                        return true;
                    }
                }
            }
            return false;
        }
    });

}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:76,代码来源:Browser.java


注:本文中的android.widget.AbsListView.setOnItemLongClickListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。