android在ViewPager显示地图View
android在ViewPager显示mapView
刚刚进来的时候:

滑动几次就变这样了

报了个错误call to OpenGL ES API with no current context (logged once per thread)
代码下载
http://download.****.net/detail/jy02231251/6985403
部分代码如下:
刚刚进来的时候:
滑动几次就变这样了
报了个错误call to OpenGL ES API with no current context (logged once per thread)
代码下载
http://download.****.net/detail/jy02231251/6985403
部分代码如下:
public class ViewPagerActivity extends Activity {
List<View> listViews;
Context context = null;
LocalActivityManager manager = null;
TabHost tabHost = null;
private ViewPager pager = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.viewpager);
context = ViewPagerActivity.this;
pager = (ViewPager) findViewById(R.id.viewpager);
//定放一个放view的list,用于存放viewPager用到的view
listViews = new ArrayList<View>();
manager = new LocalActivityManager(this, true);
manager.dispatchCreate(savedInstanceState);
Intent i1 = new Intent(context, SzActivity.class);
listViews.add(getView("A", i1));
Intent i2 = new Intent(context, SzActivity.class);
listViews.add(getView("B", i2));
Intent i3 = new Intent(context, SzActivity.class);
listViews.add(getView("C", i3));
tabHost = (TabHost) findViewById(R.id.tabhost);
tabHost.setup();
tabHost.setup(manager);
//这儿主要是自定义一下tabhost中的tab的样式
RelativeLayout tabIndicator1 = (RelativeLayout) LayoutInflater.from(this).inflate(R.layout.tabwidget, null);
TextView tvTab1 = (TextView)tabIndicator1.findViewById(R.id.tv_title);
tvTab1.setText("第一页");
RelativeLayout tabIndicator2 = (RelativeLayout) LayoutInflater.from(this).inflate(R.layout.tabwidget,null);
TextView tvTab2 = (TextView)tabIndicator2.findViewById(R.id.tv_title);
tvTab2.setText("第二页");
RelativeLayout tabIndicator3 = (RelativeLayout) LayoutInflater.from(this).inflate(R.layout.tabwidget,null);
TextView tvTab3 = (TextView)tabIndicator3.findViewById(R.id.tv_title);
tvTab3.setText("第三页");
Intent intent = new Intent(context,EmptyActivity.class);
//注意这儿Intent中的activity不能是自身 比如“A”对应的是T1Activity,后面intent就new的T3Activity的。
tabHost.addTab(tabHost.newTabSpec("A").setIndicator(tabIndicator1).setContent(intent));
tabHost.addTab(tabHost.newTabSpec("B").setIndicator(tabIndicator2).setContent(intent));
tabHost.addTab(tabHost.newTabSpec("C").setIndicator(tabIndicator3).setContent(intent));
pager .setAdapter(new MyPageAdapter(listViews));
pager .setOnPageChangeListener(new OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
//当viewPager发生改变时,同时改变tabhost上面的currentTab
tabHost.setCurrentTab(position);
}
@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
}
@Override
public void onPageScrollStateChanged(int arg0) {
}
});
//点击tabhost中的tab时,要切换下面的viewPager
tabHost.setOnTabChangedListener(new OnTabChangeListener() {
@Override
public void onTabChanged(String tabId) {
if ("A".equals(tabId)) {
pager.setCurrentItem(0);
}
if ("B".equals(tabId)) {
pager.setCurrentItem(1);
}
if ("C".equals(tabId)) {
pager.setCurrentItem(2);
}
}
});
}
private View getView(String id, Intent intent) {
return manager.startActivity(id, intent).getDecorView();
}
private class MyPageAdapter extends PagerAdapter {