本文整理汇总了Java中android.widget.ListAdapter.isEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java ListAdapter.isEnabled方法的具体用法?Java ListAdapter.isEnabled怎么用?Java ListAdapter.isEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.ListAdapter
的用法示例。
在下文中一共展示了ListAdapter.isEnabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isEnabled
import android.widget.ListAdapter; //导入方法依赖的package包/类
/**
* Returns true if the item at the specified position is
* not a separator.
*
* @param position Position of the item whose data we want
*/
@Override
public boolean isEnabled(int position)
{
for (ListAdapter piece : pieces)
{
int size = piece.getCount();
if (position < size)
{
return (piece.isEnabled(position));
}
position -= size;
}
return (false);
}
示例2: addTouchables
import android.widget.ListAdapter; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void addTouchables(ArrayList<View> views) {
final int count = getChildCount();
final int firstPosition = mFirstPosition;
final ListAdapter adapter = mAdapter;
if (adapter == null) {
return;
}
for (int i = 0; i < count; i++) {
final View child = getChildAt(i);
if (adapter.isEnabled(firstPosition + i)) {
views.add(child);
}
child.addTouchables(views);
}
}
示例3: addTouchables
import android.widget.ListAdapter; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void addTouchables(ArrayList<View> views) {
final int count = getChildCount();
final int firstPosition = mFirstPosition;
final ListAdapter adapter = mAdapter;
if (adapter == null) {
return;
}
for (int i = 0; i < count; i++) {
final View child = getChildAt(i);
if (adapter.isEnabled(firstPosition + i)) {
views.add(child);
}
child.addTouchables(views);
}
}
示例4: dispatchPopulateAccessibilityEvent
import android.widget.ListAdapter; //导入方法依赖的package包/类
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
boolean populated = super.dispatchPopulateAccessibilityEvent(event);
if (!populated) {
int itemCount = 0;
int currentItemIndex = getSelectedItemPosition();
ListAdapter adapter = getAdapter();
if (adapter != null) {
int count = adapter.getCount();
if (count < 15) {
for (int i = 0; i < count; i++) {
if (adapter.isEnabled(i)) {
itemCount++;
} else if (i <= currentItemIndex) {
currentItemIndex--;
}
}
} else {
itemCount = count;
}
}
event.setItemCount(itemCount);
event.setCurrentItemIndex(currentItemIndex);
}
return populated;
}
示例5: isEnabled
import android.widget.ListAdapter; //导入方法依赖的package包/类
/**
* If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call.
* Otherwise, return true.
*/
public boolean isEnabled(int position) {
final ListAdapter adapter = mListAdapter;
if (adapter != null) {
return adapter.isEnabled(position);
} else {
return true;
}
}
示例6: lookForSelectablePosition
import android.widget.ListAdapter; //导入方法依赖的package包/类
protected int lookForSelectablePosition(int position, boolean lookDown) {
ListAdapter adapter = this.mAdapter;
if (adapter == null || isInTouchMode()) {
return -1;
}
int count = adapter.getCount();
if (!this.mAreAllItemsSelectable) {
if (lookDown) {
position = Math.max(0, position);
while (position < count && !adapter.isEnabled(position)) {
position++;
}
} else {
position = Math.min(position, count - 1);
while (position >= 0 && !adapter.isEnabled(position)) {
position--;
}
}
if (position < 0 || position >= count) {
return -1;
}
return position;
} else if (position < 0 || position >= count) {
return -1;
} else {
return position;
}
}
示例7: onFocusChanged
import android.widget.ListAdapter; //导入方法依赖的package包/类
protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
ListAdapter adapter = this.mAdapter;
int closetChildIndex = -1;
int closestChildLeft = 0;
if (!(adapter == null || !gainFocus || previouslyFocusedRect == null)) {
previouslyFocusedRect.offset(getScrollX(), getScrollY());
if (adapter.getCount() < getChildCount() + this.mFirstPosition) {
this.mLayoutMode = 0;
layoutChildren();
}
Rect otherRect = this.mTempRect;
int minDistance = Integer.MAX_VALUE;
int childCount = getChildCount();
int firstPosition = this.mFirstPosition;
for (int i = 0; i < childCount; i++) {
if (adapter.isEnabled(firstPosition + i)) {
View other = getChildAt(i);
other.getDrawingRect(otherRect);
offsetDescendantRectToMyCoords(other, otherRect);
int distance = AbsHListView.getDistance(previouslyFocusedRect, otherRect, direction);
if (distance < minDistance) {
minDistance = distance;
closetChildIndex = i;
closestChildLeft = other.getLeft();
}
}
}
}
if (closetChildIndex >= 0) {
setSelectionFromLeft(this.mFirstPosition + closetChildIndex, closestChildLeft);
} else {
requestLayout();
}
}
示例8: lookForSelectablePosition
import android.widget.ListAdapter; //导入方法依赖的package包/类
/**
* Find a position that can be selected (i.e., is not a separator).
*
* @param position
* The starting position to look at.
* @param lookDown
* Whether to look down for other positions.
* @return The next selectable position starting at position and then
* searching either up or down. Returns {@link #INVALID_POSITION} if
* nothing can be found.
*/
@Override
protected int lookForSelectablePosition(int position, boolean lookDown) {
final ListAdapter adapter = mAdapter;
if (adapter == null || isInTouchMode()) {
return INVALID_POSITION;
}
final int count = adapter.getCount();
if (!mAreAllItemsSelectable) {
if (lookDown) {
position = Math.max(0, position);
while (position < count && !adapter.isEnabled(position)) {
position++;
}
} else {
position = Math.min(position, count - 1);
while (position >= 0 && !adapter.isEnabled(position)) {
position--;
}
}
if (position < 0 || position >= count) {
return INVALID_POSITION;
}
return position;
} else {
if (position < 0 || position >= count) {
return INVALID_POSITION;
}
return position;
}
}
示例9: onInitializeAccessibilityNodeInfo
import android.widget.ListAdapter; //导入方法依赖的package包/类
@Override
public void onInitializeAccessibilityNodeInfo(View host,
AccessibilityNodeInfoCompat info) {
super.onInitializeAccessibilityNodeInfo(host, info);
final int position = getPositionForView(host);
final ListAdapter adapter = getAdapter();
if ((position == INVALID_POSITION) || (adapter == null)) {
return;
}
if (!isEnabled() || !adapter.isEnabled(position)) {
return;
}
if (position == getSelectedItemPosition()) {
info.setSelected(true);
info.addAction(AccessibilityNodeInfoCompat.ACTION_CLEAR_SELECTION);
} else {
info.addAction(AccessibilityNodeInfoCompat.ACTION_SELECT);
}
if (isClickable()) {
info.addAction(AccessibilityNodeInfoCompat.ACTION_CLICK);
info.setClickable(true);
}
if (isLongClickable()) {
info.addAction(AccessibilityNodeInfoCompat.ACTION_LONG_CLICK);
info.setLongClickable(true);
}
}
示例10: dispatchPopulateAccessibilityEvent
import android.widget.ListAdapter; //导入方法依赖的package包/类
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
boolean populated = super.dispatchPopulateAccessibilityEvent(event);
// If the item count is less than 15 then subtract disabled items from the count and
// position. Otherwise ignore disabled items.
if (!populated) {
int itemCount = 0;
int currentItemIndex = getSelectedItemPosition();
ListAdapter adapter = getAdapter();
if (adapter != null) {
final int count = adapter.getCount();
if (count < 15) {
for (int i = 0; i < count; i++) {
if (adapter.isEnabled(i)) {
itemCount++;
} else if (i <= currentItemIndex) {
currentItemIndex--;
}
}
} else {
itemCount = count;
}
}
event.setItemCount(itemCount);
event.setCurrentItemIndex(currentItemIndex);
}
return populated;
}
示例11: lookForSelectablePosition
import android.widget.ListAdapter; //导入方法依赖的package包/类
int lookForSelectablePosition(int position, boolean lookDown) {
ListAdapter adapter = this.mAdapter;
if (adapter == null || isInTouchMode()) {
return -1;
}
int count = adapter.getCount();
if (!this.mAreAllItemsSelectable) {
if (lookDown) {
position = Math.max(0, position);
while (position < count && !adapter.isEnabled(position)) {
position++;
}
} else {
position = Math.min(position, count - 1);
while (position >= 0 && !adapter.isEnabled(position)) {
position--;
}
}
if (position < 0 || position >= count) {
return -1;
}
return position;
} else if (position < 0 || position >= count) {
return -1;
} else {
return position;
}
}
示例12: onFocusChanged
import android.widget.ListAdapter; //导入方法依赖的package包/类
protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
int closetChildIndex = -1;
if (gainFocus && previouslyFocusedRect != null) {
previouslyFocusedRect.offset(getScrollX(), getScrollY());
ListAdapter adapter = this.mAdapter;
if (adapter.getCount() < getChildCount() + this.mFirstPosition) {
this.mLayoutMode = 0;
layoutChildren();
}
Rect otherRect = this.mTempRect;
int minDistance = ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED;
int childCount = getChildCount();
int firstPosition = this.mFirstPosition;
for (int i = 0; i < childCount; i++) {
if (adapter.isEnabled(firstPosition + i)) {
View other = getChildAt(i);
other.getDrawingRect(otherRect);
offsetDescendantRectToMyCoords(other, otherRect);
int distance = PLA_AbsListView.getDistance(previouslyFocusedRect, otherRect,
direction);
if (distance < minDistance) {
minDistance = distance;
closetChildIndex = i;
}
}
}
}
if (closetChildIndex >= 0) {
setSelection(this.mFirstPosition + closetChildIndex);
} else {
requestLayout();
}
}
示例13: addTouchables
import android.widget.ListAdapter; //导入方法依赖的package包/类
public void addTouchables(ArrayList<View> views) {
int count = getChildCount();
int firstPosition = this.mFirstPosition;
ListAdapter adapter = this.mAdapter;
if (adapter != null) {
for (int i = 0; i < count; i++) {
View child = getChildAt(i);
if (adapter.isEnabled(firstPosition + i)) {
views.add(child);
}
child.addTouchables(views);
}
}
}
示例14: lookForSelectablePosition
import android.widget.ListAdapter; //导入方法依赖的package包/类
private int lookForSelectablePosition(int position, boolean lookDown) {
ListAdapter adapter = this.mAdapter;
if (adapter == null || isInTouchMode()) {
return -1;
}
int count = adapter.getCount();
if (!adapter.areAllItemsEnabled()) {
if (lookDown) {
position = Math.max(0, position);
while (position < count && !adapter.isEnabled(position)) {
position++;
}
} else {
position = Math.min(position, count - 1);
while (position >= 0 && !adapter.isEnabled(position)) {
position--;
}
}
if (position < 0 || position >= count) {
return -1;
}
return position;
} else if (position < 0 || position >= count) {
return -1;
} else {
return position;
}
}
示例15: isEnabled
import android.widget.ListAdapter; //导入方法依赖的package包/类
public boolean isEnabled(int position) {
ListAdapter adapter = this.mListAdapter;
if (adapter != null) {
return adapter.isEnabled(position);
}
return true;
}