6

uiautomator を使用してリストビューのオプションをクリックする Android アプリがあります。ListView は次のようになります。

ここに画像の説明を入力

Full Benchmark リスト アイテムをクリックしようとしていますが、コードがリスト アイテムを認識しません。これは私が持っているものです:

UiScrollable listView = new UiScrollable(new UiSelector().scrollable(
        true).className("android.widget.ListView"));

UiObject item1 = listView.getChildByText(new UiSelector()
.className(android.widget.TextView.class.getName()),
        "Full Benchmark");

item1.click();

助けていただければ幸いです!

4

3 に答える 3

9

これが私が見つけてリストビューの項目をクリックするために使用するものです:

//Find and click a ListView item
public void clickListViewItem(String name) throws UiObjectNotFoundException {
    UiScrollable listView = new UiScrollable(new UiSelector());
    listView.setMaxSearchSwipes(100);
    listView.scrollTextIntoView(name);
    listView.waitForExists(5000);
    UiObject listViewItem = listView.getChildByText(new UiSelector()
            .className(android.widget.TextView.class.getName()), ""+name+"");
    listViewItem.click();
    System.out.println("\""+name+"\" ListView item was clicked.");
}

だからあなたの場合、それは

clickListViewItem("Full Benchmark")

または:

UiScrollable listView = new UiScrollable(new UiSelector());
listView.setMaxSearchSwipes(100);
listView.scrollTextIntoView(name);
listView.waitForExists(5000);
UiObject listViewItem = listView.getChildByText(new UiSelector()
        .className(android.widget.TextView.class.getName()), "Full Benchmark");
listViewItem.click();
于 2013-06-14T20:04:32.760 に答える
0

ネストされた ViewGroup 内に 2 つの TextView があり、おそらく LinearLayout です。選考基準に欠けているようです。

于 2013-06-08T00:15:08.620 に答える