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

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

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

ListView.performItemClick介绍

暂无

代码示例

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

lv.performItemClick(wv, position, 0);

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

@Test
public void testPerformItemClick_ShouldFireOnItemClickListener() throws Exception {
 listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  @Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
   transcript.add("item was clicked: " + position);
  }
 });
 listView.performItemClick(null, 0, -1);
 assertThat(transcript).containsExactly("item was clicked: 0");
}

代码示例来源: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: robolectric/robolectric

@Test
public void givenItemIsNotCheckedAndChoiceModeIsMultiple_whenPerformingItemClick_thenItemShouldBeChecked() {
 prepareListAdapter().withChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
 int positionToClick = anyListIndex();
 listView.performItemClick(null, positionToClick, 0);
 assertThat(listView.getCheckedItemPositions().get(positionToClick)).isTrue();
 assertThat(listView.getCheckedItemCount()).isEqualTo(1);
}

代码示例来源:origin: huxq17/XRefreshView

@Override
public boolean performItemClick(View view, int position, long id) {
  if (view instanceof WrapperView) {
    view = ((WrapperView) view).mItem;
  }
  return super.performItemClick(view, position, id);
}

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

@Test
public void givenItemIsCheckedAndChoiceModeIsMultiple_whenPerformingItemClick_thenItemShouldNotBeChecked() {
 prepareListAdapter().withChoiceMode(ListView.CHOICE_MODE_MULTIPLE).withAnyItemChecked();
 listView.performItemClick(null, checkedItemPosition, 0);
 assertFalse(listView.getCheckedItemPositions().get(checkedItemPosition));
}

代码示例来源:origin: takahirom/PreLollipopTransition

@Override
  public void run() {
    assertTrue(listView.performItemClick(listView.getChildAt(0), 0, 0));
  }
});

代码示例来源:origin: tony-Shx/Swface

@Override
public boolean performItemClick(View view, int position, long id) {
  if (view instanceof WrapperView) {
    view = ((WrapperView) view).mItem;
  }
  return super.performItemClick(view, position, id);
}

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

ListView accountListView = (ListView) findViewById(R.id.accountListing);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_view_item,         R.id.nameTextView, currentAccounts);
accountListView.setAdapter(adapter);
accountListView.performItemClick(adapter, 0, 0);

代码示例来源:origin: mttkay/calculon

public void run() {
    View itemView = getAdapter().getView(position, null, listView);
    assertNotNull("item view at position " + position + " was null", itemView);
    listView.performItemClick(itemView, position, itemView.getId());
  }
}, true);

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

ListView list = preferenceActivity.getListView();
list.performItemClick(list, 1, list.getItemIdAtPosition(1));

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

public void onListViewItemClick(){
     Activity activity = getActivity();
     final ListView listView = (ListView)activity.findViewById(android.R.id.list);
     getInstrumentation().runOnMainSync(new Runnable() {
      @Override
      public void run() {
        listView.performItemClick(listView.getAdapter().getView(0, null, null), 0, listView.getItemIdAtPosition(0));
      }
    });
}

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

private void fragItemClick(final int index) throws Throwable {
  final ListView listview = mListFrag.getListView();
  runTestOnUiThread(new Runnable() {
    @Override
    public void run() {
      listview.requestFocusFromTouch();
      listview.performItemClick(listview, index, index);
    }
  });
  Thread.sleep(250); // ==> fix the problem
  assertFalse(mListFrag.isVisible());
}

代码示例来源:origin: lessthanoptimal/BoofAndroidDemo

private void moveToSelected( String target ) {
  int matched = -1;
  for (int i = 0; i < qrcodes.size(); i++) {
    if( qrcodes.get(i).message.equals(target)) {
      matched = i;
      break;
    }
  }
  if( matched != -1 ) {
    listView.smoothScrollToPosition(matched);
    listView.performItemClick(listView.getChildAt(matched),matched,
        listView.getItemIdAtPosition(matched));
  }
}

代码示例来源:origin: googlecodelabs/android-topeka

@Override
public void setUserInput(Bundle savedInput) {
  if (savedInput == null) {
    return;
  }
  mAnswers = savedInput.getBooleanArray(KEY_ANSWERS);
  if (mAnswers == null) {
    return;
  }
  final ListAdapter adapter = mListView.getAdapter();
  for (int i = 0; i < mAnswers.length; i++) {
    mListView.performItemClick(mListView.getChildAt(i), i, adapter.getItemId(i));
  }
}

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

public void run() {
  lv.performItemClick(lv,4,0);

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

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
  mAdapter.swapCursor(data); // or changeCursor(data) as explained below
  getListView().postDelayed(new Runnable() {
    @Override
    public void run() {
      ListView listView = getListView(); // Save a local reference rather than calling `getListView()` three times
      listView.setSelection(selectedposition);
      listView.performItemClick(listView.getChildAt(0), selectedposition, selectedposition);
    }
  }, 500);
}

代码示例来源:origin: googlecodelabs/android-topeka

@Override
public void setUserInput(Bundle savedInput) {
  if (savedInput == null) {
    return;
  }
  mAnswers = savedInput.getBooleanArray(KEY_ANSWERS);
  if (mAnswers == null) {
    initAnswerSpace();
    return;
  }
  ListAdapter adapter = mListView.getAdapter();
  for (int i = 0; i < mAnswers.length; i++) {
    mListView.performItemClick(mListView.getChildAt(i), i, adapter.getItemId(i));
  }
}

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

@Override
  public void run() {
    MyLog.v(methodExt, "onPerformClick " + msgLog);
    // One of the two should work
    viewToClick.performClick();
    listView.performItemClick(
        viewToClick,
        position + listView.getHeaderViewsCount(), listItemId);
    MyLog.v(methodExt, "afterClick " + msgLog);
  }
});

相关文章

ListView类方法