android.widget.ListAdapter.getItem()方法的使用及代码示例

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

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

ListAdapter.getItem介绍

暂无

代码示例

代码示例来源:origin: TonicArtos/StickyGridHeaders

@Override
public Object getItem(int position) {
  if (mDelegate == null) {
    return null;
  }
  return mDelegate.getItem(position);
}

代码示例来源:origin: arcadefire/nice-spinner

@Override public Object getItemInDataset(int position) {
    return baseAdapter.getItem(position);
  }
}

代码示例来源:origin: arcadefire/nice-spinner

@Override public Object getItem(int position) {
  return baseAdapter.getItem(position >= selectedIndex ? position + 1 : position);
}

代码示例来源:origin: chentao0707/SimplifyReader

@Override
public Object getItem(int position) {
  if (mAdapter != null) {
    List<Object> items = new ArrayList<Object>(mItemsPerRow);
    for (int i = 0; i < mItemsPerRow; ++i) {
      int p = position * mItemsPerRow + i;
      if (p < mAdapter.getCount()) {
        items.add(mAdapter.getItem(p));
      }
    }
    return items;
  }
  return null;
}

代码示例来源:origin: beworker/pinned-section-listview

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
  Item item = (Item) getListView().getAdapter().getItem(position);
  if (item != null) {
    Toast.makeText(this, "Item " + position + ": " + item.text, Toast.LENGTH_SHORT).show();
  } else {
    Toast.makeText(this, "Item " + position, Toast.LENGTH_SHORT).show();
  }
}

代码示例来源:origin: chentao0707/SimplifyReader

public Object getItem(int position) {
  // Header (negative positions will throw an ArrayIndexOutOfBoundsException)
  int numHeaders = getHeadersCount();
  if (position < numHeaders) {
    return mHeaderViewInfos.get(position).data;
  }
  // Adapter
  final int adjPosition = position - numHeaders;
  int adapterCount = 0;
  if (mAdapter != null) {
    adapterCount = mAdapter.getCount();
    if (adjPosition < adapterCount) {
      return mAdapter.getItem(adjPosition);
    }
  }
  // Footer (off-limits positions will throw an ArrayIndexOutOfBoundsException)
  return mFooterViewInfos.get(adjPosition - adapterCount).data;
}

代码示例来源:origin: seven332/EhViewer

@Override
public void setListAdapter(ListAdapter adapter) {
 if (adapter == null) {
  super.setListAdapter(null);
  return;
 }
 int count = adapter.getCount();
 List<PreferenceActivity.Header> headers = new ArrayList<>(count);
 for (int i = 0; i < count; ++i) {
  headers.add((PreferenceActivity.Header) adapter.getItem(i));
 }
 super.setListAdapter(new HeaderAdapter(this, headers, R.layout.item_preference_header, true));
}

代码示例来源:origin: ksoichiro/Android-ObservableScrollView

if (adjPosition < adapterCount) {
  if (adjPosition < mAdapter.getCount()) {
    return mAdapter.getItem(adjPosition);
  } else {
    return null;

代码示例来源:origin: liaohuqiu/android-GridViewWithHeaderAndFooter

if (adjPosition < adapterCount) {
  if (adjPosition < mAdapter.getCount()) {
    return mAdapter.getItem(adjPosition);
  } else {
    return null;

代码示例来源:origin: UweTrottmann/SeriesGuide

@Override
public Object getItem(int position) {
  return mAdapter.getItem(position);
}

代码示例来源:origin: UweTrottmann/SeriesGuide

@Override
public Object getItem(int position) {
  return mDelegate.getItem(position);
}

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

public class BlahBlahActivity extends PreferenceActivity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    addPreferencesFromResource(R.xml.account_options_prefs);

    ListView listView = getListView();
    listView.setOnItemLongClickListener(new OnItemLongClickListener() {
      @Override
      public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
        ListView listView = (ListView) parent;
        ListAdapter listAdapter = listView.getAdapter();
        Object obj = listAdapter.getItem(position);
        if (obj != null && obj instanceof View.OnLongClickListener) {
          View.OnLongClickListener longListener = (View.OnLongClickListener) obj;
          return longListener.onLongClick(view);
        }
        return false;
      }
    });
  }
}

代码示例来源:origin: Neamar/KISS

@Override
  public void onItemClick(ListAdapter adapter, View view, int position) {
    @StringRes int stringId = ((ListPopup.Item) adapter.getItem(position)).stringId;
    popupMenuClickHandler(view.getContext(), parent, stringId, parentView);
  }
});

代码示例来源:origin: ukanth/afwall

private void selectAllWifi(boolean flag) {
  if (this.listview == null) {
    this.listview = (ListView) this.findViewById(R.id.listview);
  }
  ListAdapter adapter = listview.getAdapter();
  int count = adapter.getCount(), item;
  if (adapter != null) {
    for (item = 0; item < count; item++) {
      PackageInfoData data = (PackageInfoData) adapter.getItem(item);
      if (data.uid != Api.SPECIAL_UID_ANY) {
        data.selected_wifi = flag;
        // addToQueue(data);
      }
      setDirty(true);
    }
    ((BaseAdapter) adapter).notifyDataSetChanged();
  }
}

代码示例来源:origin: ukanth/afwall

private void selectAllLAN(boolean flag) {
  if (this.listview == null) {
    this.listview = (ListView) this.findViewById(R.id.listview);
  }
  ListAdapter adapter = listview.getAdapter();
  if (adapter != null) {
    int count = adapter.getCount(), item;
    for (item = 0; item < count; item++) {
      PackageInfoData data = (PackageInfoData) adapter.getItem(item);
      if (data.uid != Api.SPECIAL_UID_ANY) {
        data.selected_lan = flag;
        //addToQueue(data);
      }
      setDirty(true);
    }
    ((BaseAdapter) adapter).notifyDataSetChanged();
  }
}

代码示例来源:origin: ukanth/afwall

private void selectAllTor(boolean flag) {
  if (this.listview == null) {
    this.listview = (ListView) this.findViewById(R.id.listview);
  }
  ListAdapter adapter = listview.getAdapter();
  if (adapter != null) {
    int count = adapter.getCount(), item;
    for (item = 0; item < count; item++) {
      PackageInfoData data = (PackageInfoData) adapter.getItem(item);
      if (data.uid != Api.SPECIAL_UID_ANY) {
        data.selected_tor = flag;
        //addToQueue(data);
      }
      setDirty(true);
    }
    ((BaseAdapter) adapter).notifyDataSetChanged();
  }
}

代码示例来源:origin: ukanth/afwall

private void selectAllRoam(boolean flag) {
  if (this.listview == null) {
    this.listview = (ListView) this.findViewById(R.id.listview);
  }
  ListAdapter adapter = listview.getAdapter();
  if (adapter != null) {
    int count = adapter.getCount(), item;
    for (item = 0; item < count; item++) {
      PackageInfoData data = (PackageInfoData) adapter.getItem(item);
      if (data.uid != Api.SPECIAL_UID_ANY) {
        data.selected_roam = flag;
        //addToQueue(data);
      }
      setDirty(true);
    }
    ((BaseAdapter) adapter).notifyDataSetChanged();
  }
}

代码示例来源:origin: ukanth/afwall

private void selectAll3G(boolean flag) {
  if (this.listview == null) {
    this.listview = (ListView) this.findViewById(R.id.listview);
  }
  ListAdapter adapter = listview.getAdapter();
  if (adapter != null) {
    int count = adapter.getCount(), item;
    for (item = 0; item < count; item++) {
      PackageInfoData data = (PackageInfoData) adapter.getItem(item);
      if (data.uid != Api.SPECIAL_UID_ANY) {
        data.selected_3g = flag;
        //addToQueue(data);
      }
      // addToQueue(data);
      setDirty(true);
    }
    ((BaseAdapter) adapter).notifyDataSetChanged();
  }
}

代码示例来源:origin: ukanth/afwall

private void clearAll() {
  if (this.listview == null) {
    this.listview = (ListView) this.findViewById(R.id.listview);
  }
  ListAdapter adapter = listview.getAdapter();
  if (adapter != null) {
    int count = adapter.getCount(), item;
    for (item = 0; item < count; item++) {
      PackageInfoData data = (PackageInfoData) adapter.getItem(item);
      data.selected_wifi = false;
      data.selected_3g = false;
      data.selected_roam = false;
      data.selected_vpn = false;
      data.selected_lan = false;
      data.selected_tor = false;
      //addToQueue(data);
      setDirty(true);
    }
    ((BaseAdapter) adapter).notifyDataSetChanged();
  }
}

代码示例来源:origin: jaredrummler/AndroidProcesses

@Override public void onListItemClick(ListView l, View v, int position, long id) {
 AndroidAppProcess process = (AndroidAppProcess) getListAdapter().getItem(position);
 ProcessInfoDialog dialog = new ProcessInfoDialog();
 Bundle args = new Bundle();
 args.putParcelable("process", process);
 dialog.setArguments(args);
 dialog.show(getActivity().getFragmentManager(), "ProcessInfoDialog");
}

相关文章