小编pat*_*asc的帖子

onActivityResult()没有在DialogFragment中执行

我一直在寻找千篇文章,但我找不到如何解决我的问题.

我有一个ImageView.当用户单击此ImageView时,将显示DialogFragment,用户可以选择在相机上拍摄新照片,也可以从库中选择照片.直到这里一切正常.

问题是,用户选择的图片应该替换ImageView中的当前图片,但是这个位是不起作用的,因为执行此代码的onActivityResult()函数没有被执行,所以ImageView中的图像始终保持不变.我会感激任何帮助,因为我没有看到或理解,为什么这个代码没有被执行.

我在用户选择图像后立即在LogCat中收到警告:

05-07 12:17:11.542: I/ActivityManager(59): Displayed activity com.android.gallery/com.android.camera.ImageGallery: 935 ms (total 935 ms)

05-07 12:17:12.812: W/FragmentActivity(3614): Activity result no fragment exists for index: 0x10001

05-07 12:17:12.862: W/InputManagerService(59): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@45fd9c38 (uid=10016 pid=317)
Run Code Online (Sandbox Code Playgroud)

Activity.java:

private ImageView imageLoader = null;
imageLoader = (ImageView) findViewById(R.id.f_imageLoader);        
imageLoader.setOnClickListener(new View.OnClickListener() {
    public void onClick(View view) {
        ImageLoaderDialog imageLoaderDialog = new ImageLoaderDialog(imageLoader);
        imageLoaderDialog.show(getSupportFragmentManager(), "imageLoaderDialog");
}
Run Code Online (Sandbox Code Playgroud)

Activity.xml:

<ImageView
    android:id="@+id/f_imageLoader"
android:layout_width="wrap_content"
    android:layout_height="0dip"
    android:layout_weight="0.20"
android:contentDescription="@string/imgDesc"
    android:src="@drawable/my_image" />
Run Code Online (Sandbox Code Playgroud)

ImageLoaderDialog.java:

//Dialog for choosing between new camera image …
Run Code Online (Sandbox Code Playgroud)

android-gallery android-camera android-imageview android-dialogfragment

11
推荐指数
1
解决办法
1801
查看次数