"setFragmentManager(getSupportFragmentManager)" 和库 : com.veinhorn.scrollggalleryview"

An IllegalStateException got with "setFragmentManager(getSupportFragmentManager)" with library : com.veinhorn.scrollggalleryview"

我正在使用 com.veinhorn.scrollgalleryview 向用户显示一些图片给 select...但是...我在调用 setFragmentManager(FragmentManager manager 时收到 IllegalStateException ScrollGalleryView class...

这是我的代码的一部分:SettingActivity.java

if (preference.getKey().equals("profile_back")) {
            View galleryView = getLayoutInflater().inflate(R.layout.dialog_gallery_view_sample, null);
            gallery = ((ScrollGalleryView)galleryView.findViewById(R.id.scroll_gallery_view))
                .setThumbnailSize(125)
                .setZoom(true)
                .setFragmentManager(getSupportFragmentManager())
                .addMedia(MediaInfo.mediaLoader(new MediaLoader() {
                    @Override
                    public boolean isImage() {
                        // TODO: Implement this method
                        return true;
                    }

                    @Override
                    public void loadMedia(Context context, ImageView imageView, MediaLoader.SuccessCallback callback) {
                        imageView.setImageBitmap(((BitmapDrawable)getResources().getDrawable(R.drawable.header_background_1)).getBitmap());
                        callback.onSuccess();
                    }

                    @Override
                    public void loadThumbnail(Context context, ImageView thumbnailView, MediaLoader.SuccessCallback callback) {
                        thumbnailView.setImageBitmap(((BitmapDrawable)getResources().getDrawable(R.drawable.header_background_1)).getBitmap());
                        callback.onSuccess();
                    }
                }));
            dialog = new android.support.v7.app.AlertDialog.Builder(getActivity())
                .setView(galleryView)
                .create();
            dialog.show();
        }

这里有一点 R.java :

public static final class id {
    public static final int action0=0x7f0800c8;
    public static final int action_bar=0x7f080074;
    public static final int action_bar_activity_content=0x7f080018;
    public static final int action_bar_container=0x7f080073;
    public static final int action_bar_root=0x7f08006f;
    public static final int action_bar_spinner=0x7f080019;
    public static final int action_bar_subtitle=0x7f080055;
    public static final int action_bar_title=0x7f080054;
    public static final int action_context_bar=0x7f080075;
    public static final int action_divider=0x7f0800cc;
    public static final int action_menu_divider=0x7f08001a;
    public static final int action_menu_presenter=0x7f08001b;
    public static final int action_mode_bar=0x7f080071;
    public static final int action_mode_bar_stub=0x7f080070;
    public static final int action_mode_close_button=0x7f080056;
    public static final int activity_chooser_view_content=0x7f080057;
    public static final int alertTitle=0x7f080063;
    public static final int alignBounds=0x7f080052;
    public static final int alignMargins=0x7f080053;
    public static final int alphaView=0x7f0800d8;
    public static final int always=0x7f08004a;
    public static final int attack_state=0x7f08009b;
    public static final int back_1=0x7f0800de;
    public static final int back_3=0x7f0800df;
    public static final int back_4=0x7f0800e0;
    public static final int backgroundImage=0x7f0800a2;
    public static final int beginning=0x7f080048;
    public static final int bottom=0x7f080029;
    public static final int buttonPanel=0x7f08005e;
    public static final int buy_boats=0x7f080099;
    public static final int buy_planes=0x7f080098;
    public static final int buy_soldiers=0x7f080096;
    public static final int buy_tanks=0x7f080097;
    public static final int buy_troups=0x7f080094;
    public static final int cancel_action=0x7f0800c9;
    public static final int center=0x7f08002a;
    public static final int center_horizontal=0x7f08002b;
    public static final int center_vertical=0x7f08002c;
    public static final int checkbox=0x7f08006c;
    public static final int chronometer=0x7f0800cf;
    public static final int clip_horizontal=0x7f080033;
    public static final int clip_vertical=0x7f080034;
    public static final int collapseActionView=0x7f08004b;
    public static final int colorPreview=0x7f080084;
    public static final int connect_profile=0x7f0800a7;
    public static final int connect_profile_list=0x7f080086;
    public static final int connect_profile_no_list=0x7f080085;
    public static final int connect_profile_pass=0x7f0800a4;
    public static final int connect_profile_pseudo=0x7f0800a3;
    public static final int container=0x7f0800e5;
    public static final int content=0x7f0800e6;
    public static final int contentPanel=0x7f080064;
    public static final int content_layout=0x7f0800c2;
    public static final int custom=0x7f08006a;
    public static final int customPanel=0x7f080069;
    public static final int decor_content_parent=0x7f080072;
    public static final int default_activity_button=0x7f08005a;
    public static final int design_menu_item_action_area=0x7f08008d;
    public static final int design_menu_item_action_area_stub=0x7f08008c;
    public static final int design_menu_item_text=0x7f08008b;
    public static final int design_navigation_view=0x7f08008a;
    public static final int disableHome=0x7f08003d;
    public static final int drawer_attack=0x7f0800ed;
    public static final int drawer_buy_equipment=0x7f0800ec;
    public static final int drawer_game_help=0x7f0800ee;
    public static final int drawer_home=0x7f0800ea;
    public static final int drawer_load_game=0x7f0800eb;
    public static final int edit_query=0x7f080076;
    public static final int end=0x7f08002d;
    public static final int end_padder=0x7f0800d4;
    public static final int enterAlways=0x7f080021;
    public static final int enterAlwaysCollapsed=0x7f080022;
    public static final int exitUntilCollapsed=0x7f080023;
    public static final int expand_activities_button=0x7f080058;
    public static final int expanded_menu=0x7f08006b;
    public static final int fill=0x7f080035;
    public static final int fill_horizontal=0x7f080036;
    public static final int fill_vertical=0x7f08002e;
    public static final int fixed=0x7f080039;
    public static final int footer=0x7f080093;
    public static final int hexEdit=0x7f0800d9;
    public static final int home=0x7f08001c;
    public static final int homeAsUp=0x7f08003e;
    public static final int horizontal=0x7f080050;
    public static final int hud=0x7f0800a8;
    public static final int hueSatView=0x7f0800d6;
    public static final int icon=0x7f08005c;
    public static final int icon_frame=0x7f0800da;
    public static final int iconics_tag_id=0x7f080000;
    public static final int ifRoom=0x7f08004c;
    public static final int image=0x7f080059;
    public static final int info=0x7f0800d3;
    public static final int item_touch_helper_previous_elevation=0x7f080017;
    public static final int left=0x7f08002f;
    public static final int leftSpacer=0x7f080095;
    public static final int line1=0x7f0800cd;
    public static final int line3=0x7f0800d1;
    public static final int list=0x7f0800dc;
    public static final int listMode=0x7f08003b;
    public static final int list_container=0x7f0800db;
    public static final int list_item=0x7f08005b;
    public static final int material_drawer_account_header=0x7f0800ab;
    public static final int material_drawer_account_header_background=0x7f0800aa;
    public static final int material_drawer_account_header_current=0x7f0800af;
    public static final int material_drawer_account_header_email=0x7f0800b2;
    public static final int material_drawer_account_header_name=0x7f0800b1;
    public static final int material_drawer_account_header_small_first=0x7f0800ac;
    public static final int material_drawer_account_header_small_second=0x7f0800ad;
    public static final int material_drawer_account_header_small_third=0x7f0800ae;
    public static final int material_drawer_account_header_text_section=0x7f0800b0;
    public static final int material_drawer_account_header_text_switcher=0x7f0800b3;
    public static final int material_drawer_animation=0x7f080002;
    public static final int material_drawer_arrow=0x7f0800b9;
    public static final int material_drawer_arrow_container=0x7f0800b8;
    public static final int material_drawer_badge=0x7f0800ba;
    public static final int material_drawer_badge_container=0x7f0800bb;
    public static final int material_drawer_description=0x7f0800b7;
    public static final int material_drawer_divider=0x7f0800b4;
    public static final int material_drawer_email=0x7f0800bd;
    public static final int material_drawer_icon=0x7f0800b5;
    public static final int material_drawer_inner_shadow=0x7f0800c1;
    public static final int material_drawer_item_container=0x7f080003;
    public static final int material_drawer_item_divider=0x7f080004;
    public static final int material_drawer_item_expandable=0x7f080005;
    public static final int material_drawer_item_mini=0x7f080006;
    public static final int material_drawer_item_mini_profile=0x7f080007;
    public static final int material_drawer_item_primary=0x7f080008;
    public static final int material_drawer_item_primary_switch=0x7f080009;
    public static final int material_drawer_item_primary_toggle=0x7f08000a;
    public static final int material_drawer_item_profile=0x7f08000b;
    public static final int material_drawer_item_profile_setting=0x7f08000c;
    public static final int material_drawer_item_secondary=0x7f08000d;
    public static final int material_drawer_item_secondary_switch=0x7f08000e;
    public static final int material_drawer_item_secondary_toggle=0x7f08000f;
    public static final int material_drawer_item_section=0x7f080010;
    public static final int material_drawer_layout=0x7f0800a9;
    public static final int material_drawer_menu_default_group=0x7f080011;
    public static final int material_drawer_name=0x7f0800b6;
    public static final int material_drawer_profileIcon=0x7f0800bc;
    public static final int material_drawer_profile_header=0x7f080012;
    public static final int material_drawer_recycler_view=0x7f0800c0;
    public static final int material_drawer_slider_layout=0x7f080013;
    public static final int material_drawer_sticky_footer=0x7f080014;
    public static final int material_drawer_sticky_header=0x7f080015;
    public static final int material_drawer_switch=0x7f0800be;
    public static final int material_drawer_toggle=0x7f0800bf;
    public static final int materialize_root=0x7f080001;
    public static final int media_actions=0x7f0800cb;
    public static final int middle=0x7f080049;
    public static final int mini=0x7f080037;
    public static final int multiply=0x7f080043;
    public static final int navigation_header_container=0x7f080089;
    public static final int never=0x7f08004d;
    public static final int new_profile=0x7f0800a6;
    public static final int new_profile_confirm=0x7f0800c7;
    public static final int new_profile_password=0x7f080092;
    public static final int new_profile_pseudo=0x7f0800c3;
    public static final int new_profile_pseudo_checker=0x7f0800c4;
    public static final int new_profile_repeat_checker=0x7f0800c6;
    public static final int new_profile_repeat_password=0x7f0800c5;
    public static final int none=0x7f080026;
    public static final int normal=0x7f080038;
    public static final int numeric_minus=0x7f08008f;
    public static final int numeric_plus=0x7f080091;
    public static final int numeric_preview=0x7f080090;
    public static final int organize=0x7f08009c;
    public static final int overflow_about_us=0x7f0800f3;
    public static final int overflow_exit=0x7f0800f4;
    public static final int overflow_feed_back=0x7f0800f2;
    public static final int overflow_overflow=0x7f0800f1;
    public static final int overflow_save_current=0x7f0800ef;
    public static final int overflow_settings=0x7f0800f0;
    public static final int parallax=0x7f080027;
    public static final int parentPanel=0x7f080060;
    public static final int pin=0x7f080028;
    public static final int profile_coins=0x7f0800a1;
    public static final int profile_iron_gold=0x7f0800a0;
    public static final int profile_pseudo=0x7f08009e;
    public static final int profile_rubis_diamonds=0x7f08009f;
    public static final int profile_show=0x7f08009d;
    public static final int progress_circular=0x7f08001d;
    public static final int progress_horizontal=0x7f08001e;
    public static final int radio=0x7f08006e;
    public static final int right=0x7f080030;
    public static final int rightSpacer=0x7f08009a;
    public static final int screen=0x7f080044;
    public static final int scroll=0x7f080024;
    public static final int scrollIndicatorDown=0x7f080068;
    public static final int scrollIndicatorUp=0x7f080065;
    public static final int scrollView=0x7f080066;
    public static final int scroll_gallery_view=0x7f08008e;
    public static final int scrollable=0x7f08003a;
    public static final int search_badge=0x7f080078;
    public static final int search_bar=0x7f080077;
    public static final int search_button=0x7f080079;
    public static final int search_close_btn=0x7f08007e;
    public static final int search_edit_frame=0x7f08007a;
    public static final int search_go_btn=0x7f080080;
    public static final int search_mag_icon=0x7f08007b;
    public static final int search_plate=0x7f08007c;
    public static final int search_src_text=0x7f08007d;
    public static final int search_voice_btn=0x7f080081;
    public static final int select_dialog_listview=0x7f080082;
    public static final int shortcut=0x7f08006d;
    public static final int showCustom=0x7f08003f;
    public static final int showHome=0x7f080040;
    public static final int showTitle=0x7f080041;
    public static final int snackbar_action=0x7f080088;
    public static final int snackbar_text=0x7f080087;
    public static final int snap=0x7f080025;
    public static final int spacer=0x7f08005f;
    public static final int split_action_bar=0x7f08001f;
    public static final int src_atop=0x7f080045;
    public static final int src_in=0x7f080046;
    public static final int src_over=0x7f080047;
    public static final int start=0x7f080031;
    public static final int status_bar_latest_event_content=0x7f0800ca;
    public static final int submit_area=0x7f08007f;
    public static final int swatchView=0x7f0800d5;
    public static final int switchWidget=0x7f0800dd;
    public static final int tabMode=0x7f08003c;
    public static final int text=0x7f0800d2;
    public static final int text2=0x7f0800d0;
    public static final int textSpacerNoButtons=0x7f080067;
    public static final int textView=0x7f0800e9;
    public static final int thumbnail=0x7f080083;
    public static final int thumbnails_container=0x7f0800e3;
    public static final int thumbnails_scroll_view=0x7f0800e2;
    public static final int time=0x7f0800ce;
    public static final int title=0x7f08005d;
    public static final int title_template=0x7f080062;
    public static final int toolbar=0x7f0800a5;
    public static final int toolbar_002=0x7f0800e4;
    public static final int top=0x7f080032;
    public static final int topPanel=0x7f080061;
    public static final int up=0x7f080020;
    public static final int useLogo=0x7f080042;
    public static final int valueView=0x7f0800d7;
    public static final int vertical=0x7f080051;
    public static final int videoProgress=0x7f0800e8;
    public static final int videoView=0x7f0800e7;
    // Here is the ID written in Logs...
    public static final int viewPager=0x7f0800e1;
    // I don't know why it isn't recognized by Android Runtime...
    public static final int view_offset_helper=0x7f080016;
    public static final int withText=0x7f08004e;
    public static final int wrap_content=0x7f08004f;
}

这是日志:LogCat Console

08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               FATAL EXCEPTION: main
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               Process: fr.zwedge.kingwarrior, PID: 18703
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               java.lang.IllegalArgumentException: No view found for id 0x7f0800e1 (fr.zwedge.kingwarrior:id/viewPager) for fragment ImageFragment{41eacc98 #0 id=0x7f0800e1}
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1059)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1613)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:570)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:163)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.support.v4.view.ViewPager.populate(ViewPager.java:1106)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.support.v4.view.ViewPager.populate(ViewPager.java:952)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1474)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.view.View.measure(View.java:16857)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:824)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:500)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.view.View.measure(View.java:16857)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5379)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1621)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.widget.LinearLayout.measureVertical(LinearLayout.java:742)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.widget.LinearLayout.onMeasure(LinearLayout.java:607)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.view.View.measure(View.java:16857)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5379)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1621)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.widget.LinearLayout.measureVertical(LinearLayout.java:742)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.widget.LinearLayout.onMeasure(LinearLayout.java:607)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.view.View.measure(View.java:16857)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5379)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.widget.FrameLayout.onMeasure(FrameLayout.java:340)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.view.View.measure(View.java:168java
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5379)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.widget.FrameLayout.onMeasure(FrameLayout.java:340)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.view.View.measure(View.java:16857)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5379)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1621)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.widget.LinearLayout.measureVertical(LinearLayout.java:742)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.widget.LinearLayout.onMeasure(LinearLayout.java:607)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.view.View.measure(View.java:16857)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5379)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.widget.FrameLayout.onMeasure(FrameLayout.java:340)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.view.View.measure(View.java:16857)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5379)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.widget.FrameLayout.onMeasure(FrameLayout.java:340)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.view.View.measure(View.java:16857)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5379)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.widget.FrameLayout.onMeasure(FrameLayout.java:340)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.view.View.measure(View.java:16857)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5379)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1621)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.widget.LinearLayout.measureVertical(LinearLayout.java:742)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.widget.LinearLayout.onMeasure(LinearLayout.java:607)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.view.View.measure(View.java:16857)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5379)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.widget.FrameLayout.onMeasure(FrameLayout.java:340)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2334)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.view.View.measure(View.java:16857)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2403)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1337)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1640)
08-16 21:37:42.854 18703 18703 E   AndroidRuntime                               at android.view.V

我不知道这个库发生了什么...它与您可以下载的示例应用程序配合得很好...

Darkball60希望你能给我一个答案

好的...我刚刚在示例应用程序中阅读了该库的实现...并且...我自己找到了解决方案...我只需要将 ScrollGalleryView 实现* 放在FragmentActivity...没什么难的...

*ScrollGalleryView 实施:

gallery = ((ScrollGalleryView)galleryView.findViewById(R.id.scroll_gallery_view))
            .setThumbnailSize(125)
            .setZoom(true)
            .setFragmentManager(getSupportFragmentManager())
            .addMedia(MediaInfo.mediaLoader(new MediaLoader() {
                @Override
                public boolean isImage() {
                    // TODO: Implement this method
                    return true;
                }

                @Override
                public void loadMedia(Context context, ImageView imageView, MediaLoader.SuccessCallback callback) {
                    imageView.setImageBitmap(((BitmapDrawable)getResources().getDrawable(R.drawable.header_background_1)).getBitmap());
                    callback.onSuccess();
                }

                @Override
                public void loadThumbnail(Context context, ImageView thumbnailView, MediaLoader.SuccessCallback callback) {
                    thumbnailView.setImageBitmap(((BitmapDrawable)getResources().getDrawable(R.drawable.header_background_1)).getBitmap());
                    callback.onSuccess();
                }
            }));

只需将其添加到新的 activity 中:GalleryActivity.java

public class GalleryActivity extends FragmentActivity {
    // onCreate with Gallery implementation
}