首页 > 解决方案 > 片段不会立即被替换

问题描述

我多次使用具有不同数据的片段,但有时片段不会立即替换。

  FunVideoFragment.prepareFun
  (
       videoSuggestionListNew.get(position).getEnTitle(),
       videoSuggestionListNew.get(position).getFaTitle(),
       videoSuggestionListNew.get(position).getLink(),
       videoSuggestionListNew.get(position).getEnText(),
       videoSuggestionListNew.get(position).getImage(),
       String.valueOf(videoSuggestionListNew.get(position).getTopicCode()),
       videoSuggestionListNew.get(position).getContentCode(),
       videoSuggestionListNew.get(position).getCategory(),
       videoSuggestionListNew.get(position).getTextPartOfSpeech(), "fun"
  );

Log.e("parimah","start2");

Helper.fragmentInflater(new FunVideoFragment(), MainActivity.mContext);

和片段代码:

@SuppressLint("ClickableViewAccessibility")
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable Bundle savedInstanceState) {

    Log.e("parimah","start3");

    rootView = inflater.inflate(R.layout.fragment_fun_video, container, false);
    initializing();

    // some function

    return rootview;
}

   public static void prepareFun
        (String enTitle, String faTitle, String url, String subtitle, String imageVideo, String topicCode, String contentCode, String category, String vocab, String type) {
    videoEnTitle = enTitle;
    videoFaTitle = faTitle;
    videoUrl = url;
    videoSubtitle = subtitle;
    videoImage = imageVideo;
    downloadedVideoName = topicCode + contentCode;

    videoTopicCode = topicCode;
    videoContentCode = contentCode;
    videoCategory = category;
    videoType = type;
    videoVocab = vocab;
}

这有时会延迟。例如:

2020-05-16 18:45:59.576 11729-11729/ir.barmanrayan.tikkaa E/parimah: start2
2020-05-16 18:46:07.729 11729-11729/ir.barmanrayan.tikkaa E/parimah: start3

如何删除此延迟并立即显示片段?

标签: androidfragment

解决方案


推荐阅读