0

私はこれで何日も立ち往生しています。HTMLを解析し、情報を5つの配列リストにソートするアクティビティがあります。各 arraylist は平日です。各配列リストを取得して、別のページのリストビューに情報を表示したいので、月曜日が1つのページに表示され、スワイプすると火曜日に移動します。

私はEclipseのデフォルトのスクロール可能なタブ+ナビゲーション用のスワイプを使用しており、そこから構築しようとしています。

したがって、基本的には、5 ページのデータに 5 つの arraylists、各ページに 1 つの arraylist を設定したいと考えています。特定のページで配列リストをリストビューに割り当てる方法はありますか?

ここに私がこれまでに持っているコードがあります

public class DisplayOnlineTimetable extends FragmentActivity {


SectionsPagerAdapter mSectionsPagerAdapter;

/**
 * The {@link ViewPager} that will host the section contents.
 */
String value;   
Document doc = null;
private ListView mainListView ;  

static ViewGroup mViewGroup;
ViewPager mViewPager;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_display_online_timetable_dummy);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the app.
    mSectionsPagerAdapter = new SectionsPagerAdapter(
            getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.display_online_timetable, menu);
    return true;
}

/**
 * A {@link FragmentPagerAdapter} that returns a fragment corresponding to
 * one of the sections/tabs/pages.
 */
public class SectionsPagerAdapter extends FragmentPagerAdapter {

    public SectionsPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int i) {
        return DummySectionFragment.newInstance(i);
    }

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

    @Override
    public CharSequence getPageTitle(int position) {
        Locale l = Locale.getDefault();
        switch (position) {
        //monday
        case 0:
            return getString(R.string.title_section1).toUpperCase(l);
            //tuesday
        case 1:
            return getString(R.string.title_section2).toUpperCase(l);
            //wednesday
        case 2:
            return getString(R.string.title_section3).toUpperCase(l);
            //thursday
        case 3:
            return getString(R.string.title_section3).toUpperCase(l);
            //friday
        case 4:
            return getString(R.string.title_section3).toUpperCase(l);
        }
        return null;
    }
}

public void createTimetable(ArrayList<SingleClass> list, Elements elements, Day day)
{

}   



private class CreateTimetables extends AsyncTask<URL, Integer, Long> 
{
    protected Long doInBackground(URL... urls) {

    }

    protected void onPostExecute(Long result) 
    {

    }
}

}

DummySectionFragment クラス

public class DummySectionFragment extends ListFragment {
private Integer arrayListId;
ViewGroup myViewGroup;
public static final String CATEGORY_POSITION = "section_number";
public static DummySectionFragment newInstance(int pos) {
    DummySectionFragment f = new DummySectionFragment();

    // Supply num input as an argument.
    Bundle args = new Bundle();
    args.putInt(CATEGORY_POSITION, pos);
    f.setArguments(args);

    return f;
}

@Override
public void onCreate(Bundle savedInstanceState) {
    //get the id for your array list
    arrayListId = getArguments() != null ? getArguments().getInt(CATEGORY_POSITION) - 1 : 1;
}

//create the list view layout
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
myViewGroup = container;
View v = inflater.inflate(R.layout.list_row, container, false);
return v;
 }

//populate the list view row
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    ArrayAdapter<SingleClass> arrayAdapter =      
 new ArrayAdapter<SingleClass>(getActivity(), android.R.id.list, R.layout.list_row);

    setListAdapter(arrayAdapter);
}

}

4

1 に答える 1