我有一个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() {
Run Code Online (Sandbox Code Playgroud)
它将数据库中的名字和姓氏显示为项目列表: 单击以显示UI
所以,今天我尝试使用Espresso与这个应用程序,我找不到点击包含文本的项目的方法.
我用的时候:
onData(anything())
.inAdapterView(withId(R.id.lvData))
.atPosition(3)
.perform(click());
Run Code Online (Sandbox Code Playgroud)
它完美地运作.但我想点击包含相应项目文本的项目.
到目前为止我尝试了什么(我在stackoverflow,google,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());
Run Code Online (Sandbox Code Playgroud)
因此,字符串"Ivan Ivanov"和项目之间可能存在差异,该项目包含来自数据库的数据:firstName+ lastName?
在我的项目中,我有很多可绘制的内容,当我需要添加新图像以绘制时,我可以放置相同的资源,因为我忘了我已经拥有它.
它不是关于XML文件的预览,这很好用.
Android Studio中的任何功能都可以预览我的所有可绘制内容而无需双击每个资源?它可以节省大量时间.
我没有在偏好中找到任何东西,也许是一些插件或者我错过了什么?
我有一个问题。我使用Glide 3.8.0。
我需要从服务器下载图像并将其放入Google地图上的标记中。
Glide.with(getBaseActivity())
.load(place.getIconUrl())
.asBitmap()
.fitCenter()
.into(new SimpleTarget<Bitmap>(50,50) {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
map.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromBitmap(resource))
.position(place.getLatLng()));
}
@Override
public void onLoadFailed(Exception e, Drawable errorDrawable) {
map.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_marker_default_logo))
.position(place.getLatLng()));
}
});
Run Code Online (Sandbox Code Playgroud)
另外,如果有一些加载错误,我有默认徽标,其大小为50x50。
我测试了2种设备上的加载-nexus 5和无名称设备(我不知道屏幕分辨率和屏幕尺寸,但尺寸与nexus 5几乎相同)
在不同的设备上,我有不同大小的标记徽标,并且我尝试
.into(new SimpleTarget<Bitmap>(50,50) 尺寸
Nexus 5,50x50与默认徽标相比要小得多,75x75比默认徽标要小,150x150与默认徽标相同
无名称设备:75x75与默认徽标相同,比默认徽标小50x50
因此,我可以使用Glide做什么使其在不同的设备上相同并且与默认徽标50x50相同(默认徽标在不同设备上看起来相同)