簡體   English   中英

啟動畫面時如何加載活動

[英]How to load activty while Splash Screen

我有一個viewpager,其中包含7張幻燈片。 但是幻燈片的內容是HTML,所以我想在啟動畫面中加載HTML的數據,然后再顯示內容。 我的內容在我的活動的InstantiateItem方法中膨脹。

@Override
    public Object instantiateItem(ViewGroup container, int position) {


        layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        HTMLPre preparer = new HTMLPre();

        String font = "SourceSansPro-Regular";


        View one = layoutInflater.inflate(R.layout.slide_type_a, container, false);


        WebView header_1_a = (WebView) one.findViewById(R.id.header_slide_type_a_1);
        preparer.loadHTLMContentHeader(getString(R.string.Aktien1_header),header_1_a,font);
        ImageView image_1_a = (ImageView) one.findViewById(R.id.image_slide_type_a_1);
        image_1_a.setImageResource(R.drawable.picture_kap01_01);
        WebView text_1_a = (WebView) one.findViewById(R.id.text_slide_type_a_1);
        preparer.loadHTLMContentText(getString(R.string.Aktien1), text_1_a,font);

        View two = layoutInflater.inflate(R.layout.slide_type_a, container, false);


        header_1_a = (WebView) two.findViewById(R.id.header_slide_type_a_1);
        preparer.loadHTLMContentHeader(getString(R.string.Aktien2_header),header_1_a,font);
        image_1_a = (ImageView) two.findViewById(R.id.image_slide_type_a_1);
        image_1_a.setImageResource(R.drawable.picture_kap01_01);
        text_1_a = (WebView) two.findViewById(R.id.text_slide_type_a_1);
        preparer.loadHTLMContentText(getString(R.string.Aktien2), text_1_a,font);


        View three = layoutInflater.inflate(R.layout.slide_type_a, container, false);

        header_1_a = (WebView) three.findViewById(R.id.header_slide_type_a_1);
        preparer.loadHTLMContentHeader(getString(R.string.Aktien3_header), header_1_a,font);
        image_1_a = (ImageView) three.findViewById(R.id.image_slide_type_a_1);
        image_1_a.setImageResource(R.drawable.boerse_antwerpen);
        text_1_a = (WebView) three.findViewById(R.id.text_slide_type_a_1);
        preparer.loadHTLMContentText(getString(R.string.Aktien3), text_1_a,font);


        View four = layoutInflater.inflate(R.layout.slide_type_a, container, false);

        header_1_a = (WebView) four.findViewById(R.id.header_slide_type_a_1);
        preparer.loadHTLMContentHeader(getString(R.string.Aktien4_header), header_1_a,font);
        image_1_a = (ImageView) four.findViewById(R.id.image_slide_type_a_1);
        image_1_a.setImageResource(R.drawable.parketthandel);
        text_1_a = (WebView) four.findViewById(R.id.text_slide_type_a_1);
        preparer.loadHTLMContentText(getString(R.string.Aktien4), text_1_a,font);



        View five = layoutInflater.inflate(R.layout.slide_type_c, container, false);

        image_1_a = (ImageView) five.findViewById(R.id.image_slide_type_c_1);
        image_1_a.setImageResource(R.drawable.parketthandel);
        text_1_a = (WebView) five.findViewById(R.id.text_slide_type_c_1);
        preparer.loadHTLMContentText(getString(R.string.Aktien5), text_1_a,font);




        View six = layoutInflater.inflate(R.layout.slide_type_c, container, false);

        image_1_a = (ImageView) six.findViewById(R.id.image_slide_type_c_1);
        image_1_a.setImageResource(R.drawable.parketthandel);
        text_1_a = (WebView) six.findViewById(R.id.text_slide_type_c_1);
        preparer.loadHTLMContentText(getString(R.string.Aktien6), text_1_a,font);


        View seven = layoutInflater.inflate(R.layout.slide_type_c, container, false);

        image_1_a = (ImageView) seven.findViewById(R.id.image_slide_type_c_1);
        image_1_a.setImageResource(R.drawable.parketthandel);
        text_1_a = (WebView) seven.findViewById(R.id.text_slide_type_c_1);
        preparer.loadHTLMContentText(getString(R.string.Aktien7), text_1_a,font);

        View eigth = layoutInflater.inflate(R.layout.slide_type_c, container, false);

        image_1_a = (ImageView) eigth.findViewById(R.id.image_slide_type_c_1);
        image_1_a.setImageResource(R.drawable.seewegevoc);
        text_1_a = (WebView) eigth.findViewById(R.id.text_slide_type_c_1);
        preparer.loadHTLMContentText(getString(R.string.Aktien8), text_1_a,font);



        View nine = layoutInflater.inflate(R.layout.startquiz_layout, container, false);
        View viewarr[] = {one, two, three, four, five, six, seven, eigth, nine};
        container.addView(viewarr[position]);


        return viewarr[position];

    }

所以現在我想加載在啟動屏幕加載時在此活動中完成的操作。 有人有想法嗎?

因此,為簡單起見,我創建了一個小示例應用程序,展示了如何創建該應用程序。

我沒有在此處復制粘貼所有代碼,而是創建了一個Gist,您可以在此處找到它。

請注意,這段代碼只是一個示例,它不會處理任何錯誤,並且絕不會針對處理許多WebView進行優化。

我知道它並不完全使用您的代碼,但是我不知道HTMLPre是什么,我只是在使用默認的方式在WebView中加載網站。

編輯:添加了整個Git存儲庫,因此可以運行完整的示例項目-在此處找到它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM