我在mainActivity的Android跑出的内存getCount将 “notifyDataSetChanged()”()
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
setContentView(R.layout.activity_main);
mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());
mAppSectionsPagerAdapter.setContext(this);
try {
final ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mAppSectionsPagerAdapter);
mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
actionBar.setSelectedNavigationItem(position);
}
});
for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
actionBar.addTab(
actionBar.newTab()
.setText(mAppSectionsPagerAdapter.getPageTitle(i))
.setTabListener(this));
}
}
catch (Exception e)
{
Log.d("myLOG", e.toString());
}
除了创建pageAdapter后,我有SingleItemActivity当我在ListViewItem的点击将打开:
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(getActivity(), SingleItemActivity.class);
intent.putExtra("id", id);
intent.putExtra("listViewID", 1);
startActivity(intent);
我在2个选项卡中有2个列表,当我点击第一个列表中的某个项目时 - 通常会打开,但是当我打开第二个选项卡并点按某个项目时,Android会与我通话:
The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged! Expected adapter item count: 2, found: 1
好吧,我改getCount将方法:
@Override
public int getCount() {
notifyDataSetChanged();
return Cache.jsonData[listViewID].length();
}
所以,当我试图从任何列表Android开放项目显示我:
Throwing OutOfMemoryError "Failed to allocate a 28 byte allocation with 4 free bytes and 4B until OOM"
有人能帮忙吗?感谢您阅读我的英语不好))