gpt4 book ai didi

Android ui test with espresso 无法使用fresco SimpleDraweeView

转载 作者:行者123 更新时间:2023-11-30 00:14:11 28 4
gpt4 key购买 nike

现在我想使用 espresso 来测试我的应用程序用户界面,但是当我使用 fresco 库时,作为 xml 中的一个 SimpleDreweeView,espresso 将失败并出现错误:

android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class com.facebook.drawee.view.SimpleDraweeView
at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:474)
at android.app.Activity.setContentView(Activity.java:2388)
at com.example.android.testing.espresso.intents.AdvancedSample.ImageViewerActivity.onCreate(ImageViewerActivity.java:45)

那么谁能帮我解决这个问题??非常感谢!!

我的 xml 文件:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/activity_horizontal_margin"
tools:context=".ImageViewerActivity">

<Button android:id="@+id/button_take_photo"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_open_camera"
android:layout_gravity="center_horizontal"
android:onClick="onOpenCamera"
android:layout_marginTop="32dp"/>

<com.facebook.drawee.view.SimpleDraweeView
android:layout_width="128dp"
android:layout_height="128dp"
android:id="@+id/imageView"
android:layout_gravity="center_horizontal"
android:layout_marginTop="32dp"
android:background="#ffdbdbdb"/>

</LinearLayout>

ImageViewActivity:

public class ImageViewerActivity extends Activity {

@VisibleForTesting
protected static final String KEY_IMAGE_DATA = "data";

private static final int REQUEST_IMAGE_CAPTURE = 1;

private SimpleDraweeView mImageView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_image_viewer);
mImageView = (SimpleDraweeView) findViewById(R.id.imageView);
}

private void dispatchTakePictureIntent() {
// Open the camera to take a photo.
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
}
}

public void onOpenCamera(View view) {
dispatchTakePictureIntent();
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// If an image is received, display it on the ImageView.
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();
if (extras == null || !extras.containsKey(KEY_IMAGE_DATA)) {
return;
}
Bitmap imageBitmap = (Bitmap) extras.get(KEY_IMAGE_DATA);
mImageView.setImageBitmap(imageBitmap);
}
}
}

我只是修改了google官方的demo,将imageview替换成simpledraweeview,而且容易出错....

最佳答案

以你的写作为例

@Override
public void onCreate() {
super.onCreate();
Fresco.initialize(this);
setContentView(R.layout.activity_image_viewer);
}

关于Android ui test with espresso 无法使用fresco SimpleDraweeView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47590254/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com