android.widget.ListView.setOnKeyListener()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(3.9k)|赞(0)|评价(0)|浏览(187)

本文整理了Java中android.widget.ListView.setOnKeyListener()方法的一些代码示例,展示了ListView.setOnKeyListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ListView.setOnKeyListener()方法的具体详情如下:
包路径:android.widget.ListView
类名称:ListView
方法名:setOnKeyListener

ListView.setOnKeyListener介绍

暂无

代码示例

代码示例来源:origin: orhanobut/dialogplus

@Override @NonNull
public View getView(@NonNull LayoutInflater inflater, ViewGroup parent) {
 View view = inflater.inflate(R.layout.dialog_list, parent, false);
 View outMostView = view.findViewById(R.id.dialogplus_outmost_container);
 outMostView.setBackgroundResource(backgroundResource);
 listView = view.findViewById(R.id.dialogplus_list);
 listView.setOnItemClickListener(this);
 listView.setOnKeyListener(new View.OnKeyListener() {
  @Override public boolean onKey(View v, int keyCode, KeyEvent event) {
   if (keyListener == null) {
    throw new NullPointerException("keyListener should not be null");
   }
   return keyListener.onKey(v, keyCode, event);
  }
 });
 headerContainer = view.findViewById(R.id.dialogplus_header_container);
 footerContainer = view.findViewById(R.id.dialogplus_footer_container);
 return view;
}

代码示例来源:origin: arimorty/floatingsearchview

mPopup.setHorizontalOffset(horizontalOffset);
mPopup.show();
mPopup.getListView().setOnKeyListener(this);
return true;

代码示例来源:origin: namndbka/QDict

private void ensureList() {
  if (mList != null) {
    return;
  }
  View root = getView();
  if (root == null) {
    throw new IllegalStateException("Content view not yet created");
  }
  View rawListView = root.findViewById(android.R.id.list);
  if (!(rawListView instanceof ListView)) {
    throw new RuntimeException(
        "Content has view with id attribute 'android.R.id.list' " + "that is not a ListView class");
  }
  mList = (ListView) rawListView;
  int count = mList.getChildCount();
  for (int i = 0; i < count; i++) {
    View v = mList.getChildAt(i);
    v.setBackgroundResource(R.drawable.ic_item_background);
  }
  mList.setOnKeyListener(mListOnKeyListener);
  mHandler.post(mRequestFocus);
}

代码示例来源:origin: stackoverflow.com

@Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
       Bundle savedInstanceState){
   //Log.d(DEBUG_TAG, "onCreateView");
   View v = inflater.inflate(R.layout.settings_tile, null);
   closeBtn = (ImageView) v.findViewById(R.id.settingsCloseButton);
   final ListView lv = (ListView) v.findViewById(android.R.id.list);
   lv.setOnKeyListener(new OnKeyListener() {
     @Override
     public boolean onKey(View v, int keyCode, KeyEvent event) {
       // TODO Auto-generated method stub
       if (event.getAction() == KeyEvent.ACTION_DOWN) {
         switch(keyCode) {
           case KeyEvent.KEYCODE_DPAD_DOWN:
             return !(lv.getSelectedItemPosition() < lv.getCount() - 1);
           case KeyEvent.KEYCODE_DPAD_UP:
             return lv.getSelectedItemPosition() == 1;
           case KeyEvent.KEYCODE_DPAD_RIGHT:
             return true;    
         }
         return false;
       }
       return false;
     }
   });
   return v;
 }

代码示例来源:origin: stackoverflow.com

+ "'android.R.id.list'");
mList.setOnKeyListener(mListOnKeyListener);
mHandler.post(mRequestFocus);

代码示例来源:origin: com.actionbarsherlock/actionbarsherlock

mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
mPopup.show();
mPopup.getListView().setOnKeyListener(this);
return true;

代码示例来源:origin: com.willowtreeapps/oak-demos

public boolean tryShow() {
  mPopup = new IcsListPopupWindow(mContext, null, R.attr.popupMenuStyle);
  mPopup.setOnDismissListener(this);
  mPopup.setOnItemClickListener(this);
  mAdapter = new MenuAdapter(mMenu);
  mPopup.setAdapter(mAdapter);
  mPopup.setModal(true);
  View anchor = mAnchorView;
  if (anchor != null) {
    final boolean addGlobalListener = mTreeObserver == null;
    mTreeObserver = anchor.getViewTreeObserver(); // Refresh to latest
    if (addGlobalListener) mTreeObserver.addOnGlobalLayoutListener(this);
    ((View_HasStateListenerSupport)anchor).addOnAttachStateChangeListener(this);
    mPopup.setAnchorView(anchor);
  } else {
    return false;
  }
  mPopup.setContentWidth(Math.min(measureContentWidth(mAdapter), mPopupMaxWidth));
  mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
  mPopup.show();
  mPopup.getListView().setOnKeyListener(this);
  return true;
}

代码示例来源:origin: derry/delion

mPopup.show();
mPopup.getListView().setItemsCanFocus(true);
mPopup.getListView().setOnKeyListener(this);

相关文章

ListView类方法