Android 在下载该页面视图文件后在“查看页面”中添加页面无法获取新页面

Android 在下载该页面视图文件后在“查看页面”中添加页面无法获取新页面,android,android-viewpager,Android,Android Viewpager,我需要在下载文件后在viewpager中添加页面 我的代码是 arrPdfFilename //declare globle 一次创建 awesomePager = (ViewPager) findViewById(R.id.awesomepager); NUM_AWESOME_VIEWS=10; awesomeAdapter = new AwesomePagerAdapter(this,arrPdfFilename); awesomePager.setAda

我需要在下载文件后在viewpager中添加页面 我的代码是

arrPdfFilename //declare globle
一次创建

awesomePager = (ViewPager) findViewById(R.id.awesomepager);
 NUM_AWESOME_VIEWS=10;
        awesomeAdapter = new AwesomePagerAdapter(this,arrPdfFilename);
        awesomePager.setAdapter(awesomeAdapter);
Finsh下载后

public void FinishedDownloadTask(String Filename)
{
arrPdfFilename[lintpdfcount]=Filename;

awesomePager.getAdapter().notifyDataSetChanged();
}
页面适配器

private class AwesomePagerAdapter extends PagerAdapter{


    @Override
    public int getCount() {
        return NUM_AWESOME_VIEWS;
    }

    /**
     * Create the page for the given position.  The adapter is responsible
     * for adding the view to the container given here, although it only
     * must ensure this is done by the time it returns from
     * {@link #finishUpdate()}.
     *
     * @param container The containing View in which the page will be shown.
     * @param position The page position to be instantiated.
     * @return Returns an Object representing the new page.  This does not
     * need to be a View, but can be some other container of the page.
     */

    private Context context;

    private String[] marrPdfFilename;

    public AwesomePagerAdapter(Context ctx,String[] arrPdfFilename)
    {
        this.context =ctx;
        this.marrPdfFilename=arrPdfFilename;
        Log.d("arrPdfFilename initial length",arrPdfFilename.length+"");
        Log.d("marrPdfFilename initial length",marrPdfFilename.length+"");
    }


    @Override
    public Object instantiateItem(final View collection, int position) {

        LayoutInflater vi = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        final View view = vi.inflate(R.layout.mainsub, null);
        final RelativeLayout RtLayout=(RelativeLayout)pdfview.findViewById(R.id.pdfviewlayout);

        String Filename=arrPdfFilename[position];


        if(Filename!=null)
        {
        Log.d("Filename",Filename);
        SetPage(context,Filename);
        runOnUiThread(new Runnable() {

            @Override
            public void run() {
                // TODO Auto-generated method stub
                //progrsspdf.setVisibility(View.VISIBLE);
                createUI(RtLayout);
                ((ViewPager) collection).addView(view,0);

            }
        });
        }
        return view;

    }

    /**
     * Remove a page for the given position.  The adapter is responsible
     * for removing the view from its container, although it only must ensure
     * this is done by the time it returns from {@link #finishUpdate()}.
     *
     * @param container The containing View from which the page will be removed.
     * @param position The page position to be removed.
     * @param object The same object that was returned by
     * {@link #instantiateItem(View, int)}.
     */

    @Override
    public void destroyItem(View collection, int position, Object view) {
        ((ViewPager) collection).removeView((RelativeLayout) view);
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view==((RelativeLayout)object);
    }



    /**
     * Called when the a change in the shown pages has been completed.  At this
     * point you must ensure that all of the pages have actually been added or
     * removed from the container as appropriate.
     * @param container The containing View which is displaying this adapter's
     * page views.
     */
    @Override
    public void finishUpdate(View arg0) {

    }

    @Override
    public void restoreState(Parcelable arg0, ClassLoader arg1) {}

    @Override
    public Parcelable saveState() {
        return null;
    }



    @Override
    public void startUpdate(View arg0) {
        //if(focusedPage>NUM_AWESOME_VIEWS)
            //Log.d("startUpdate",focusedPage+"-");

    }
    @Override
    public void notifyDataSetChanged()
    {
        Log.d("SSSSSSS","notify data set changed");
        super.notifyDataSetChanged();
    }
    @Override
    public int getItemPosition(Object object) {
        Log.d("getItemPosition","getItemPosition");
        return POSITION_NONE;
    }

}
它工作正常,但新添加的页面将不会被滚动,请帮助我。。。。 谢谢