Java tutorial
/* * Costituzione Italiana 4.0 * Copyright (C) 2012 * Gnufabio <me@gnufabio.com>, Enrix835 <enrico.trt@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.gnufabio.costituzione.components; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import com.gnufabio.costituzione.fragments.DetailedFragment; import java.util.List; public class DetailedFragmentAdapter extends FragmentPagerAdapter { SingleEntry[] mList; Note[] mListNotes; DetailedFragment[] mFragments; FragmentActivity activity; public DetailedFragmentAdapter(FragmentManager fm, List<SingleEntry> list, List<Note> mNote, FragmentActivity activity) { super(fm); mList = new SingleEntry[list.size()]; mList = list.toArray(mList); mListNotes = new Note[mNote.size()]; mListNotes = mNote.toArray(mListNotes); mFragments = new DetailedFragment[mList.length]; for (int i = 0; i < mList.length; i++) { mFragments[i] = new DetailedFragment(mList[i], mListNotes[i]); } } @Override public DetailedFragment getItem(int position) { return (DetailedFragment) mFragments[position]; } @Override public int getCount() { return mFragments.length; } @Override public String getPageTitle(int position) { return mList[position].getTitle(); } public void updateNote(int pos, Note newvalue) { mListNotes[pos] = newvalue; } }