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

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

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

ListView.getCheckedItemPosition介绍

暂无

代码示例

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

ListView lw = ((AlertDialog)dialog).getListView();
Object checkedItem = lw.getAdapter().getItem(lw.getCheckedItemPosition());

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
 boolean result=
   host.performAction(item.getItemId(),
             modeView.getCheckedItemPosition());
 if (item.getItemId() == R.id.remove) {
  activeMode.finish();
 }
 return(result);
}

代码示例来源:origin: android-hacker/VirtualXposed

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
  super.onRestoreInstanceState(savedInstanceState);
  if (mAlwaysUseOption) {
    final int checkedPos = mListView.getCheckedItemPosition();
    final boolean enabled = checkedPos != ListView.INVALID_POSITION;
    mLastSelected = checkedPos;
    mAlwaysButton.setEnabled(enabled);
    mOnceButton.setEnabled(enabled);
    if (enabled) {
      mListView.setSelection(checkedPos);
    }
  }
}

代码示例来源:origin: android-hacker/VirtualXposed

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
  final int checkedPos = mListView.getCheckedItemPosition();
  final boolean hasValidSelection = checkedPos != ListView.INVALID_POSITION;
  if (mAlwaysUseOption && (!hasValidSelection || mLastSelected != checkedPos)) {
    mAlwaysButton.setEnabled(hasValidSelection);
    mOnceButton.setEnabled(hasValidSelection);
    if (hasValidSelection) {
      mListView.smoothScrollToPosition(checkedPos);
    }
    mLastSelected = checkedPos;
  } else {
    startSelected(position, false);
  }
}

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public void onSaveInstanceState(Bundle state) {
 super.onSaveInstanceState(state);
 state.putInt(STATE_CHECKED, getListView().getCheckedItemPosition());
}

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public void onSaveInstanceState(Bundle state) {
 super.onSaveInstanceState(state);
 state.putInt(STATE_CHECKED, getListView().getCheckedItemPosition());
}

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public void onSaveInstanceState(Bundle state) {
 super.onSaveInstanceState(state);
 state.putInt(STATE_CHECKED, getListView().getCheckedItemPosition());
}

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public void onSaveInstanceState(Bundle state) {
 super.onSaveInstanceState(state);
 state.putInt(STATE_CHECKED, getListView().getCheckedItemPosition());
}

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public void onSaveInstanceState(Bundle state) {
 super.onSaveInstanceState(state);
 if (getView() != null) {
  state.putInt(STATE_CHECKED,
         getListView().getCheckedItemPosition());
 }
}

代码示例来源:origin: xfumihiro/ViewInspector

@Override public void onClick(DialogInterface dialog, int which) {
  restoreOpenedMenu();
  listener.onViewRootSelected(
    (View) listView.getItemAtPosition(listView.getCheckedItemPosition()));
 }
});

代码示例来源:origin: commonsguy/cw-omnibus

@Override
 public void run() {
  if (lorem != null && lorem.isVisible()) {
   drawer.setItemChecked(0, true);
  }
  else if (content != null && content.isVisible()) {
   drawer.setItemChecked(1, true);
  }
  else {
   int toClear=drawer.getCheckedItemPosition();
   if (toClear >= 0) {
    drawer.setItemChecked(toClear, false);
   }
  }
 }
};

代码示例来源:origin: robolectric/robolectric

@Test
public void givenChoiceModeIsNone_whenGettingCheckedItemPosition_thenReturnInvalidPosition() {
 prepareListAdapter().withChoiceMode(ListView.CHOICE_MODE_NONE);
 assertThat(listView.getCheckedItemPosition()).isEqualTo(ListView.INVALID_POSITION);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void givenNoItemsChecked_whenGettingCheckedItemOisition_thenReturnInvalidPosition() {
 prepareListAdapter().withChoiceMode(ListView.CHOICE_MODE_SINGLE);
 assertThat(listView.getCheckedItemPosition()).isEqualTo(ListView.INVALID_POSITION);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void givenChoiceModeIsMultiple_whenGettingCheckedItemPosition_thenReturnInvalidPosition() {
 prepareListAdapter().withChoiceMode(ListView.CHOICE_MODE_MULTIPLE).withAnyItemChecked();
 assertThat(listView.getCheckedItemPosition()).isEqualTo(ListView.INVALID_POSITION);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void givenChoiceModeIsSingle_whenGettingCheckedItemPosition_thenReturnPosition() {
 prepareListAdapter().withChoiceMode(ListView.CHOICE_MODE_SINGLE).withAnyItemChecked();
 assertThat(listView.getCheckedItemPosition()).isEqualTo(checkedItemPosition);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void givenChoiceModeIsSingleAndAnItemIsChecked_whenSettingChoiceModeToNone_thenGetCheckedItemPositionShouldReturnInvalidPosition() {
 prepareListAdapter().withChoiceMode(ListView.CHOICE_MODE_SINGLE).withAnyItemChecked();
 listView.setChoiceMode(ListView.CHOICE_MODE_NONE);
 assertThat(listView.getCheckedItemPosition()).isEqualTo(ListView.INVALID_POSITION);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void givenItemIsCheckedAndChoiceModeIsSingle_whenPerformingItemClick_thenItemShouldBeChecked() {
 prepareListAdapter().withChoiceMode(ListView.CHOICE_MODE_SINGLE).withAnyItemChecked();
 listView.performItemClick(null, checkedItemPosition, 0);
 assertThat(listView.getCheckedItemPosition()).isEqualTo(checkedItemPosition);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void givenItemIsNotCheckedAndChoiceModeIsSingle_whenPerformingItemClick_thenItemShouldBeChecked() {
 prepareListAdapter().withChoiceMode(ListView.CHOICE_MODE_SINGLE);
 int positionToClick = anyListIndex();
 listView.performItemClick(null, positionToClick, 0);
 assertThat(listView.getCheckedItemPosition()).isEqualTo(positionToClick);
}

代码示例来源:origin: sismics/reader

@Override
protected void onSaveInstanceState(Bundle outState) {
  super.onSaveInstanceState(outState);
  outState.putInt("drawerItemSelected", drawerList.getCheckedItemPosition());
}

代码示例来源:origin: vanilla-music/vanilla

@Override
public void onDismiss(DialogInterface dialog)
{
  ListView list = ((AlertDialog)dialog).getListView();
  int which = list.getCheckedItemPosition();
  CheckBox reverseSort = (CheckBox)list.findViewById(R.id.reverse_sort);
  if (reverseSort.isChecked()) {
    which = ~which;
  }
  mPagerAdapter.setSortMode(which);
}

相关文章

ListView类方法