片段列表视图Android检索数据

时间:2015-08-09 19:38:13

标签: android android-fragments android-tabs

我在刷卡中检索数据时遇到问题,并且在正在检索的活动中但是在滑动选项卡中它无法在字符串中说错误。我知道如何实现选项卡但有问题来检索数据

假日活动

    setContentView(R.layout.activity_holiday);

    //noinspection ConstantConditions
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setIcon(R.drawable.dl);
    ParseObject.registerSubclass(Holiday.class);


    mAdapter = new HolidayAdapter(this, new ArrayList<Holiday>());

    ListView mListView = (ListView) findViewById(R.id.holiday_list);
    mListView.setAdapter(mAdapter);




    updateData();
}
public void updateData() {
    ParseQuery<Holiday> query = ParseQuery.getQuery(Holiday.class);

    query.setCachePolicy(ParseQuery.CachePolicy.CACHE_THEN_NETWORK);
    query.findInBackground(new FindCallback<Holiday>() {
        @Override
        public void done(List<Holiday> holidays, com.parse.ParseException e) {

            if (holidays != null) {
                mAdapter.clear();
                for (int i = 0; i < holidays.size(); i++) {
                    mAdapter.add(holidays.get(i));
                }
            }
        }
    });
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            // app icon in action bar clicked; goto parent activity.
            this.finish();
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}

}

我想在标签

中检索数据

TabPageAdapter

public class TabPagerAdapter extends FragmentStatePagerAdapter {
public TabPagerAdapter(FragmentManager fm) {
    super(fm);
    // TODO Auto-generated constructor stub
}

@Override
public Fragment getItem(int i) {
    switch (i) {
    case 0:

        return new Holiday();
    case 1:

        return new Main();

    }
    return null;

}

@Override
public int getCount() {
    // TODO Auto-generated method stub
    return 2; //No of Tabs you can give your number of tabs
}


}

有没有办法让我可以从标签中的解析中检索数据而不是活动enter code here

0 个答案:

没有答案