Верхний макет не отображается в других частях фрагмента - PullRequest
0 голосов
/ 21 октября 2019

Исходный макет: Screenshot 1

Измененный макет: Screenshot 2

По мере того как изображения приведены, почему макет не появляется и в других разделах? Я использую фрагменты и нажимаю на элементы, загружая другой фрагмент, где макет Top просто исчезает

Вот метод OnItemClicked:

 public void onItemClick(DataModel item) {
    if (item != null) {
        String name = item.text;
        if (name.equalsIgnoreCase(HOME_HEALTH) || name.equalsIgnoreCase(Constant.health[1]) || name.equalsIgnoreCase(Constant.health[2])) {
            Intent i = new Intent(getActivity(), activity_health_profile.class);
            startActivity(i);
        }

        else if (name.equalsIgnoreCase(HOME_EDU_FORUM) || name.equalsIgnoreCase(Constant.edu_forum[1]) || name.equalsIgnoreCase(Constant.edu_forum[2])) {

            Intent i = new Intent(getActivity(), EduForumOuterParent.class);
            startActivity(i);

        }

        else if (name.equalsIgnoreCase(HOME_LIBRARY) || name.equalsIgnoreCase(Constant.library[1]) || name.equalsIgnoreCase(Constant.library[2])) {

            loadFragment(new FragmentShop(), HOME_LIBRARY);
            Functions.unfocusOnHome((Button) getActivity().findViewById(R.id.tab_btn_home));
            current_item = HOME_LIBRARY;
            activity.adapter.notifyDataSetChanged();
            activity.scrollTO(HOME_LIBRARY);

        } else if (name.equalsIgnoreCase(HOME_NEWS) || name.equalsIgnoreCase(Constant.news[1]) || name.equalsIgnoreCase(Constant.news[2])) {
            loadFragment(new FragmentNews(), "NEWS");

            Functions.unfocusOnHome((Button) getActivity().findViewById(R.id.tab_btn_home));
            current_item = getResources().getString(R.string.news);

            activity.adapter.notifyDataSetChanged();
            activity.scrollTO(HOME_NEWS);

        } else if (name.equalsIgnoreCase(HOME_EVENTS) || name.equalsIgnoreCase(Constant.events[1]) || name.equalsIgnoreCase(Constant.events[2])) {

            loadFragment(new FragmentEvent(), HOME_EVENTS);
            Functions.unfocusOnHome((Button) getActivity().findViewById(R.id.tab_btn_home));
            current_item = getResources().getString(R.string.events);
            activity.adapter.notifyDataSetChanged();
            activity.scrollTO(HOME_EVENTS);
        } else if (name.equalsIgnoreCase(HOME_FUNDRAISING) || name.equalsIgnoreCase(Constant.fundraising[1]) || name.equalsIgnoreCase(Constant.fundraising[2])) {
            loadFragment(new FundraisingFragment(), "FUNDRAISING");
            Functions.unfocusOnHome((Button) getActivity().findViewById(R.id.tab_btn_home));
            current_item = getResources().getString(R.string.fundraising);
            activity.adapter.notifyDataSetChanged();
            activity.scrollTO(HOME_FUNDRAISING);
        } else if (name.equalsIgnoreCase(HOME_ANNOUNCEMENT_H) || name.equalsIgnoreCase(Constant.announcement[1]) || name.equalsIgnoreCase(Constant.announcement[2])) {
            loadFragment(new FragmentAnnouncement(), HOME_ANNOUNCEMENT_H);
            Functions.unfocusOnHome((Button) getActivity().findViewById(R.id.tab_btn_home));
            current_item = getResources().getString(R.string.announcement);
            activity.adapter.notifyDataSetChanged();
            activity.scrollTO(HOME_ANNOUNCEMENT_H);
        } else if (name.equalsIgnoreCase(HOME_VOLUNTEER) || name.equalsIgnoreCase(Constant.volunteer[1]) || name.equalsIgnoreCase(Constant.volunteer[2])) {


            SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext());
            String checkInVal = preferences.getString("checkIn", "");

            if (checkInVal != null && checkInVal.equals("yes")) {
                redirectToDetailVolunteerPage();
            } else {

                loadFragment(new VolunteerFragment(), HOME_VOLUNTEER);
                Functions.unfocusOnHome((Button) getActivity().findViewById(R.id.tab_btn_home));
                current_item = HOME_VOLUNTEER;
                activity.adapter.notifyDataSetChanged();
                activity.scrollTO(HOME_VOLUNTEER);
            }

        }
   }
        else if (name.equalsIgnoreCase(HOME_PHOTO) || name.equalsIgnoreCase(Constant.photo[1]) || name.equalsIgnoreCase(Constant.photo[2])) {
            loadFragment(new FragmentPhotosAlbum(), HOME_PHOTO_ALBUM);
            Functions.unfocusOnHome((Button) getActivity().findViewById(R.id.tab_btn_home));
            current_item = HOME_PHOTO;
            activity.adapter.notifyDataSetChanged();
            activity.scrollTO(HOME_PHOTO);
        } else if (name.equalsIgnoreCase(HOME_VIDEO_ALBUM) ||
                name.equalsIgnoreCase(HOME_MEDIA)
                || name.equalsIgnoreCase(Constant.media[1]) ||
                name.equalsIgnoreCase(Constant.media[2])) {
            loadFragment(new FragmentVideoAlbum(), HOME_VIDEO_ALBUM);
            Functions.unfocusOnHome((Button) getActivity().findViewById(R.id.tab_btn_home));
            current_item = HOME_VIDEO_ALBUM;
            activity.adapter.notifyDataSetChanged();
            activity.scrollTO(HOME_VIDEO_ALBUM);
        } else if (name.equalsIgnoreCase(HOME_RESOURCES) || name.equalsIgnoreCase(Constant.resources[1]) || name.equalsIgnoreCase(Constant.resources[2])

                || name.equalsIgnoreCase("Edu Bank")) {


            //  loadFragment(new FragmentResources(), "RESOURCES");

            Intent intent = new Intent(activity, GKOuter.class);
            startActivity(intent);
            Functions.unfocusOnHome((Button) getActivity().findViewById(R.id.tab_btn_home));
            current_item = getResources().getString(R.string.resources);
            activity.adapter.notifyDataSetChanged();
            activity.scrollTO(HOME_RESOURCES);


        } else if (name.equalsIgnoreCase(HOME_DIRECTORY)  || name.equalsIgnoreCase(Constant.directory[1]) || name.equalsIgnoreCase(Constant.directory[2])) {
            loadFragment(new FragmentDirectory(), "DIRECTORY");
            Functions.unfocusOnHome((Button) getActivity().findViewById(R.id.tab_btn_home));
            current_item = getResources().getString(R.string.directory);
            activity.adapter.notifyDataSetChanged();
            activity.scrollTO(HOME_DIRECTORY);
        } else if (name.equalsIgnoreCase(HOME_PAYMENT) || name.equalsIgnoreCase(Constant.payment[1]) || name.equalsIgnoreCase(Constant.payment[2])) {

            if (EasyPreference.with(getActivity(), PRE_KEY)
                    .getString(PRE_USER_LANGUAGE, PRE_LANGUAGE_ENGLISH).equalsIgnoreCase(PRE_LANGUAGE_ASSEMESS)) {
                activity.setTitle("মাচুল পৰিশোধ", false, true);
                fees_url = "https://www.ourschoolzone.org/fees/payumoneyaggregator.php?school_id=" + EasyPreference.with(getActivity(), PRE_KEY).getString(PRE_SCHOOL_ID, "1") + "&student_id=" + pref.getString(MY_PREFS_STUDENT_ID, "") + "&language=assamese";
            } else if (EasyPreference.with(getActivity(), PRE_KEY)
                    .getString(PRE_USER_LANGUAGE, PRE_LANGUAGE_ENGLISH).equalsIgnoreCase(PRE_LANGUAGE_THI)) {
                activity.setTitle("ค่าธรรมเนียม การชำระเงิน", false, true);
                fees_url = "https://www.ourschoolzone.org/fees/payumoneyaggregator.php?school_id=" + EasyPreference.with(getActivity(), PRE_KEY).getString(PRE_SCHOOL_ID, "1") + "&student_id=" + pref.getString(MY_PREFS_STUDENT_ID, "") + "&language=thai";
            } else {
                activity.setTitle("FEES PAYMENT", false, true);
                fees_url = "https://www.ourschoolzone.org/fees/payumoneyaggregator.php?school_id=" + EasyPreference.with(getActivity(), PRE_KEY).getString(PRE_SCHOOL_ID, "1") + "&student_id=" + pref.getString(MY_PREFS_STUDENT_ID, "") + "&language=english";
            }

            Bundle bundle = new Bundle();

            bundle.putString("website", fees_url);

            // Create new fragment and transaction
            Fragment newFragment = new fragment_fees_webview();
            newFragment.setArguments(bundle);
            getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragmentContainer, newFragment, "WEBDETAILS").addToBackStack(null).commit();
            Functions.iNumberOfLoadedFragments++;
            Functions.unfocusOnHome((Button) getActivity().findViewById(R.id.tab_btn_home));


        } else if (name.equalsIgnoreCase(HOME_SUPPLY) || name.equalsIgnoreCase(Constant.supply[1]) || name.equalsIgnoreCase(Constant.supply[2])) {
            loadFragment(new FragmentSupply(), HOME_SUPPLY);
            Functions.unfocusOnHome((Button) getActivity().findViewById(R.id.tab_btn_home));
            current_item = HOME_SUPPLY;
            activity.adapter.notifyDataSetChanged();
            activity.scrollTO(HOME_SUPPLY);

        } else if (name.equalsIgnoreCase(HOME_SCHOOL_RANK) || name.equalsIgnoreCase(Constant.shool_rank[1]) || name.equalsIgnoreCase(Constant.shool_rank[2])) {
            loadFragment(new FragmentSchoolRank(), HOME_SCHOOL_RANK);
            Functions.unfocusOnHome((Button) getActivity().findViewById(R.id.tab_btn_home));
            current_item = HOME_SCHOOL_RANK;
            activity.adapter.notifyDataSetChanged();
            activity.scrollTO(HOME_SCHOOL_RANK);

        } else if (name.equalsIgnoreCase(HOME_GOOGLE_CLASS_ROOM) || name.equalsIgnoreCase(Constant.google_classroom[1]) || name.equalsIgnoreCase(Constant.google_classroom[2])) {

        } else if (name.equalsIgnoreCase(HOME_LUNCH_MENU) || name.equalsIgnoreCase(Constant.lunch_menu[1]) || name.equalsIgnoreCase(Constant.lunch_menu[2])) {
            loadFragment(new FragmentLunchMenu(), HOME_LUNCH_MENU);
            Functions.unfocusOnHome((Button) getActivity().findViewById(R.id.tab_btn_home));
            current_item = HOME_LUNCH_MENU;
            activity.adapter.notifyDataSetChanged();
            activity.scrollTO(HOME_LUNCH_MENU);

        } else if (name.equalsIgnoreCase("Absent Report") || name.equalsIgnoreCase(Constant.absent_report[1]) || name.equalsIgnoreCase(Constant.absent_report[2])) {

            loadFragment(new FragmentAbsentReport(), HOME_ABSENT_REPORT);
            Functions.unfocusOnHome((Button) getActivity().findViewById(R.id.tab_btn_home));
            current_item = HOME_ABSENT_REPORT;
            activity.adapter.notifyDataSetChanged();
            activity.scrollTO(HOME_ABSENT_REPORT);

        } else if (name.equalsIgnoreCase(HOME_REVIEW) || name.equalsIgnoreCase(Constant.review[1]) || name.equalsIgnoreCase(Constant.review[2])) {

            loadFragment(new FragmentReview(), HOME_REVIEW);
            Functions.unfocusOnHome((Button) getActivity().findViewById(R.id.tab_btn_home));
            current_item = HOME_REVIEW;
            activity.adapter.notifyDataSetChanged();
            activity.scrollTO(HOME_REVIEW);

        } else if (name.equalsIgnoreCase(HOME_ABOUT_US) || name.equalsIgnoreCase(Constant.about_us[1]) || name.equalsIgnoreCase(Constant.about_us[2])) {
            loadFragment(new FragmentAboutus(), HOME_ABOUT_US);
            Functions.unfocusOnHome((Button) getActivity().findViewById(R.id.tab_btn_home));
            current_item = HOME_ABOUT_US;
            activity.adapter.notifyDataSetChanged();
            activity.scrollTO(HOME_ABOUT_US);

        } else if (name.equalsIgnoreCase(HOME_SCHOOL_BUS) || name.equalsIgnoreCase(Constant.school_bus[1]) || name.equalsIgnoreCase(Constant.school_bus[2])) {
            loadFragment(new FragmentSelectBus(), HOME_SCHOOL_BUS);
            Functions.unfocusOnHome((Button) getActivity().findViewById(R.id.tab_btn_home));
            current_item = HOME_SCHOOL_BUS;
            activity.adapter.notifyDataSetChanged();
            activity.scrollTO(HOME_SCHOOL_BUS);
        } else if (name.equalsIgnoreCase(HOME_HELP) || name.equalsIgnoreCase(Constant.help[1]) || name.equalsIgnoreCase(Constant.help[2])) {
            Bundle bundle = new Bundle();

            bundle.putString("website", "http://help.schoolzoneapp.com/");
            //Toast.makeText(getActivity().getApplicationContext(), modelEvent.getEventTitle(), Toast.LENGTH_SHORT).show();
            if (EasyPreference.with(getActivity(), PRE_KEY)
                    .getString(PRE_USER_LANGUAGE, PRE_LANGUAGE_ENGLISH).equalsIgnoreCase(PRE_LANGUAGE_ASSEMESS)) {
                activity.setTitle("সাহায্য", false, true);
            } else if (EasyPreference.with(getActivity(), PRE_KEY)
                    .getString(PRE_USER_LANGUAGE, PRE_LANGUAGE_ENGLISH).equalsIgnoreCase(PRE_LANGUAGE_THI)) {
                activity.setTitle("ช่วยด้วย", false, true);
            } else {
                activity.setTitle(HOME_HELP, false, true);
            }
            // Create new fragment and transaction
            Fragment newFragment = new fragment_webview();
            newFragment.setArguments(bundle);
            getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragmentContainer, newFragment, "WEBDETAILS").addToBackStack(null).commit();
            Functions.iNumberOfLoadedFragments++;
            Functions.unfocusOnHome((Button) getActivity().findViewById(R.id.tab_btn_home));

        } else if (name.equalsIgnoreCase(HOME_CLASS_ROOM) || name.equalsIgnoreCase(Constant.classroom[1]) || name.equalsIgnoreCase(Constant.classroom[2])) {

            Intent i = new Intent(activity, CalanderActivity.class);
            startActivity(i);
        } else if (name.equalsIgnoreCase(HOME_SCHOOL_DIARY) || name.equalsIgnoreCase(Constant.school_diary[1]) || name.equalsIgnoreCase(Constant.school_diary[2])) {
            loadFragment(new FragmentSchoolDiary(), HOME_SCHOOL_DIARY);
            Functions.unfocusOnHome((Button) getActivity().findViewById(R.id.tab_btn_home));
            current_item = HOME_SCHOOL_DIARY;
            activity.adapter.notifyDataSetChanged();
            activity.scrollTO(HOME_SCHOOL_DIARY);
        } else if (name.equalsIgnoreCase(HOME_EXAMINATION) || name.equalsIgnoreCase(Constant.examination[1]) || name.equalsIgnoreCase(Constant.examination[2])) {
            loadFragment(new FragmentExamination(), HOME_EXAMINATION);
            Functions.unfocusOnHome((Button) getActivity().findViewById(R.id.tab_btn_home));
            current_item = HOME_EXAMINATION;
            activity.adapter.notifyDataSetChanged();
            activity.scrollTO(HOME_EXAMINATION);
        }
    }
}

Что я могу сделать, так как этот макет несеткаждой кнопке в клике внутри фрагмента? Любая помощь будет оценена.

Это фрагмент_announcement.xml, который работает FINE:

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="2dp"
        app:cardBackgroundColor="@android:color/transparent"
        app:cardCornerRadius="3dp"
        app:cardElevation="1dp">

        <android.support.v4.widget.SwipeRefreshLayout
            android:id="@+id/newsSwipeRefreshLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v7.widget.RecyclerView
                xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/rvNews"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
        </android.support.v4.widget.SwipeRefreshLayout>
    </android.support.v7.widget.CardView>
</LinearLayout>

Это фрагмент_ Notice.xml, который не работает нормально:

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="10dp"
        app:cardBackgroundColor="@android:color/transparent"
        app:cardCornerRadius="3dp"
        app:cardElevation="1dp">

        <android.support.v4.widget.SwipeRefreshLayout
            android:id="@+id/newsSwipeRefreshLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v7.widget.RecyclerView
                android:id="@+id/rvNews"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

        </android.support.v4.widget.SwipeRefreshLayout>
    </android.support.v7.widget.CardView>
</LinearLayout>
...