データベースからのデータを表示するListViewがあります。エスプレッソ。 「アダプタデータのロード」エラー。
db = new DB(this);
db.open();
String[] from = new String[]{DB.COLUMN_FIRSTNAME, DB.COLUMN_LASTNAME};
int[] to = new int[]{android.R.id.text1, android.R.id.text2};
scAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_activated_2, null, from, to, 0);
lvData = (ListView) findViewById(R.id.lvData);
lvData.setAdapter(scAdapter);
lvData.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
lvData.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() {
それは、項目のリストとしてデータベースから、姓と名を示しています Click to UI
だから、今日私はこのアプリでエスプレッソを使用しようとしたと私はへの道を見つけることができませんテキストを含む項目をクリックします。
私が使用:
onData(anything())
.inAdapterView(withId(R.id.lvData))
.atPosition(3)
.perform(click());
それは完璧に動作します。しかし、私は対応する項目のテキストを含む項目をクリックしたいと思います。私がこれまで試したどのような
(私はstackoverflowの時に見つけたすべてのもの、グーグル、githubの、など):
onView(allOf(withText("Ivan Ivanov"))).perform(click())
onData(allOf(is(instanceOf(MainActivity.class)),is("Ivan Ivanov")))
.inAdapterView(withId(R.id.lvData))
.perform(click());
onData(hasToString(startsWith("v")))
.inAdapterView(withId(R.id.lvData))
.atPosition(0).perform(click());
onData(instanceOf(MainActivity.class))
.inAdapterView(withId(R.id.lvData))
.atPosition(0)
.check(matches(hasDescendant(withText("Ivan Ivanov"))));
onData(anything()).inAdapterView(withContentDescription("Ivan Ivanov"))
.atPosition(0).perform(click());
ので、多分、文字列「イワン・イワノフ」と項目の間に違いがありますされますデータベースからのデータを含んでいます:firstName
+ lastName
?
それは動作します。ありがとう! – pligosv