Java 如何在启动屏幕时加载Activity

Java 如何在启动屏幕时加载Activity,java,android,html,android-layout,Java,Android,Html,Android Layout,我有一个包含7张幻灯片的viewpager。但是幻灯片的内容是HTML,所以我想在splashscreen中加载HTML的数据,然后我想显示内容。我的内容在活动的InstanceItem方法中膨胀 @Override public Object instantiateItem(ViewGroup container, int position) { layoutInflater = (LayoutInflater) getSystemService(Context.L

我有一个包含7张幻灯片的viewpager。但是幻灯片的内容是HTML,所以我想在splashscreen中加载HTML的数据,然后我想显示内容。我的内容在活动的InstanceItem方法中膨胀

@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];

    }

现在我想加载在splashscreen加载时在此活动中执行的操作。有人有什么想法吗?

所以为了简单起见,我创建了一个小样本应用程序,展示了如何创建它

我没有在这里复制粘贴所有代码,而是创建了一个要点,您可以找到

请注意,此代码只是一个示例,不考虑任何错误处理之类的问题,而且它绝不适合处理大量的
WebView
s

我知道它并不完全使用您的代码,但我不知道什么是
HTMLPre
,我只是使用
WebView
中加载网站的默认方式


编辑:添加了整个Git存储库,因此可以运行完整的示例项目-找到它。

没有
活动的
instatiateItem
方法-您可能指的是
页面编辑器的方法?解决方法是在
活动
的XML布局中的
查看页面
上方放置一个视图,并隐藏
查看页面
,直到加载完成。该视图将是您的splashscreen。splashscreen基本上可以是一个填充屏幕的视图,以及该视图顶部的进度条。但是,在加载视图页面元素之前,如何在视图页面顶部临时设置视图?当viewpager完成时,如何知道另一个视图?在我的查看页面的活动类中是否有类似setconten的内容,我会添加我的loadscreen视图?在
活动的XML中,您可以在
查看页面
的顶部添加
视图
,然后您可以添加一个侦听器,以便在代码(
HTMLPre
)加载完网站时使用。监听器可以是你的
活动
,加载完成后,你会隐藏你放在
查看页面
顶部的
视图
@Darwind你能给我一个例子吗?我是如何在查看页面上加载像图像之类的视图的?你可以看到我当前的代码是一个新的答案。我有一个相对的布局,其中包含了查看页面。但是,当我更改relativelayout的背景时,它不会覆盖幻灯片布局的内容。。。