本文整理汇总了Java中android.widget.AbsListView.setOnItemClickListener方法的典型用法代码示例。如果您正苦于以下问题:Java AbsListView.setOnItemClickListener方法的具体用法?Java AbsListView.setOnItemClickListener怎么用?Java AbsListView.setOnItemClickListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.AbsListView
的用法示例。
在下文中一共展示了AbsListView.setOnItemClickListener方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateView
import android.widget.AbsListView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_iniciative, container, false);
// Set the adapter
mListView = (AbsListView) view.findViewById(android.R.id.list);
mListView.setAdapter(mAdapter);
// Set OnItemClickListener so we can be notified on item clicks
mListView.setOnItemClickListener(this);
return view;
}
示例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;
}
});
}