1
    @Override
    public int getCount() {
        return mFragments.size();
    }

    @Override
    public Fragment getItem(int arg0) {
        return mFragments.get(arg0);
    }
}


    InfoPageFragment(ArrayList<String> entities, int type) {
        Log.i("Entity:", String.valueOf(type));
        this.entities = entities;
        infotype = type;
        keys = new ArrayList<String>(entities.size());
    }

    private ArrayList<Map<String, Object>> getData() {
        String[] info = null;
        Map<String, Object> infomap = null;
        ArrayList<Map<String, Object>> listviewdata = new ArrayList<Map<String, Object>>();
        Log.i("Data", String.valueOf(infotype));
        for (int i = 0; i < entities.size(); i++) {
            info = entities.get(i).split(String.valueOf('\u0216'));
            if (info.length != 3) {
                continue;
            }
            infomap = new LinkedHashMap<String, Object>();
            infomap.put("txt_infodata", info[1]);
            infomap.put("txt_infodate", info[2]);
            listviewdata.add(infomap);
            keys.add(info[0]);
        }
        return listviewdata;
    }

    private void initListView(View view) {
        ListView lst_info = (ListView) view.findViewById(R.id.lst_infolist);
        lst_info.setAdapter(new SimpleAdapter(view.getContext(), getData(),
                R.layout.listitem_info, new String[] { "txt_infodata",
                        "txt_infodate" }, new int[] { R.id.txt_infodata,
                        R.id.txt_infodate }));
        lst_info.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1,
                    int arg2, long arg3) {
                String dir = null;
                switch (infotype) {
                case 0:
                    dir = mApp.getFile(mApp.Pag_News);
                    break;
                case 1:
                    dir = mApp.getFile(mApp.Pag_Rule);
                    break;
                case 2:
                    dir = mApp.getFile(mApp.Pag_Download);
                    break;
                }
                Intent it = new Intent(Intent.ACTION_VIEW, Uri.parse(dir
                        + keys.get(arg2)));
                arg1.getContext().startActivity(it);
            }

        });
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_newslist, container,
                false);
        initListView(view);
        return view;
    }
}

    public void presentFragment(int id) {
    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    Fragment fragment = initFragment(id);
    ft.replace(R.id.fragment_container, fragment);
    ft.commit();
    preSelected = id;
}

構造はFragment [ViewPager [3 Fragment]]で、ビューページャーを初めて開始するとき(内部に3つのフラグメントがあります)、完全に機能しますが、別のフラグメントをそれに置き換えて代わりに置き換えると、フラグメント1とフラグメント3レビューできますが、フラグメント 2 は空白です!!! 私はアンドロイド開発の新しい手であり、長い間この問題に夢中です!!!

私はアンドロイド開発の新しい手です

4

0 に答える 0