Wednesday, April 23, 2014

android display mapView in ViewPager


posts by jy02231251 edited 2014-03-03 11:27:14
Just came in:



Slide several times had changed so the



Report a mistake call to OpenGL ES API with no current context (logged once per thread)

Download
http://download.csdn.net/detail/jy02231251/6985403

Part of the code is as follows:
 
public class ViewPagerActivity extends Activity {

List 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);

/ / Set to put an amp view of list, used for storing viewPager view
listViews = new ArrayList ();

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);


/ / Here is mainly about style
tabhost custom tab in theRelativeLayout tabIndicator1 = (RelativeLayout) LayoutInflater.from (this) inflate (R.layout.tabwidget, null);.
TextView tvTab1 = (TextView) tabIndicator1.findViewById (R.id.tv_title);
tvTab1.setText ("First");

RelativeLayout tabIndicator2 = (RelativeLayout) LayoutInflater.from (this) inflate (R.layout.tabwidget, null);.
TextView tvTab2 = (TextView) tabIndicator2.findViewById (R.id.tv_title);
tvTab2.setText ("second page");

RelativeLayout tabIndicator3 = (RelativeLayout) LayoutInflater.from (this) inflate (R.layout.tabwidget, null);.
TextView tvTab3 = (TextView) tabIndicator3.findViewById (R.id.tv_title);
tvTab3.setText ("third page");

Intent intent = new Intent (context, EmptyActivity.class);
/ / Note Intent can not be here in the activity itself such as "A" corresponds T1Activity, behind the T3Activity of intent on the new.
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) {
/ / When viewPager change, while changing tabhost above currentTab
tabHost.setCurrentTab (position);
}
@ Override
public void onPageScrolled (int arg0, float arg1, int arg2) {
}
@ Override
public void onPageScrollStateChanged (int arg0) {
}
});


/ / Click tabhost the tab when you want to switch the following 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 {

private List list;

private MyPageAdapter (List list) {
this.list = list;
}

@ Override
public void destroyItem (View view, int position, Object arg2) {
ViewPager pViewPager = ((ViewPager) view);
pViewPager.removeView (list.get (position));
}

@ Override
public void finishUpdate (View arg0) {
}

@ Override
public int getCount () {
return list.size ();
}

@ Override
public Object instantiateItem (View view, int position) {
ViewPager pViewPager = ((ViewPager) view);
pViewPager.addView (list.get (position));
return list.get (position);
}

@ Override
public boolean isViewFromObject (View arg0, Object arg1) {
return arg0 == arg1;
}

@ Override
public void restoreState (Parcelable arg0, ClassLoader arg1) {
}

@ Override
public Parcelable saveState () {
return null;
}

@ Override
public void startUpdate (View arg0) {
}

}

}


public class SzActivity extends Activity {

private MapView mapView;
private TextView textView;

@ Override
public void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.activity_sz);
this.mapView = (MapView) this.findViewById (R.id.map);

/ * This.mapView.addLayer (new ArcGISTiledMapServiceLayer (
Constant.ArcGISTiledMapServiceLayer)); * /
this.mapView.addLayer (new ArcGISTiledMapServiceLayer (
"Http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"));

mapView.setMaxResolution (100);
mapView.setMinResolution (100);
mapView.setResolution (100);
onResume ();
}

@ Override
protected void onResume () {
super.onResume ();
}

public boolean dispatchTouchEvent (MotionEvent event) {
return true;
}
}



android: layout_width = "match_parent"
android: layout_height = "match_parent"
android: orientation = "vertical">

android: id = "@ + id / map"
android: layout_width = "fill_parent"
android: layout_height = "817dp"
android: layout_weight = "0.01"
initExtent = "11372996.8949145647, 2768747.335369462, 11532138.6351355437, 2854203.85101166">


<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Top big God help us to see it?
Reply:
I have many years of cervical spondylosis. .
Reply:
Multiple test several times.

Are you saying that zoom in, zoom?
Reply:
reference to the third floor huxiweng reply:
multiple test several times.

Are you saying that zoom in, zoom?


I put in viewpaper inside mapview control displays map viewpaper can slide slide the white side becomes the
Reply:
What is your problem solved?
Reply:
The problem has been solved
Reply:
references, 5th Floor qinlianfa reply:
ask your question solved?
has been resolved

No comments:

Post a Comment