最初我的想法是创建一个使用选项卡式活动的子项列表。 1-父母有一个或多个孩子。 2-使用排球我希望使用选项卡式活动将逻辑传递给manege为每个孩子自己创建一个新的片段。
我尝试了,因为你可以在下面看到我的活动,之后你会看到我的适配器:
let locationManager1: CLLocationManager // your location manager
func addBoundry(loc: CLLocation)
{
if let loc: CLLocation! = locationManager1.location {
let center: CLLocationCoordinate2D = loc!.coordinate
let lat: CLLocationDegrees = center.latitude
let long: CLLocationDegrees = center.longitude
var points = [CLLocationCoordinate2DMake(lat,long),CLLocationCoordinate2DMake(lat,long),CLLocationCoordinate2DMake(lat,long),CLLocationCoordinate2DMake(lat,long)]
let polygon = MKPolygon(coordinates: &points, count: points.count)
mapView.addOverlay(polygon)
} else {
print("no location...")
}
}
}
private ViewPager mViewPager = null;
private ChildAdapter pagerAdapter = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_child);
// Set up the ViewPager with the sections adapter.
pagerAdapter = new ChildAdapter();
mViewPager = (ViewPager) findViewById(R.id.view_pager);
mViewPager.setAdapter(pagerAdapter);
LayoutInflater inflater = context.getLayoutInflater();
FrameLayout v0 = (FrameLayout) inflater.inflate(R.layout.fragment_profile, null);
pagerAdapter.addView(v0, 0);
}
//-----------------------------------------------------------------------------
// Here's what the app should do to add a view to the ViewPager.
public void addView(View newPage) {
int pageIndex = pagerAdapter.addView(newPage);
// You might want to make "newPage" the currently displayed page:
mViewPager.setCurrentItem(pageIndex, true);
}
//-----------------------------------------------------------------------------
// Here's what the app should do to remove a view from the ViewPager.
public void removeView(View defunctPage) {
int pageIndex = pagerAdapter.removeView(mViewPager, defunctPage);
// You might want to choose what page to display, if the current page was "defunctPage".
if (pageIndex == pagerAdapter.getCount())
pageIndex--;
mViewPager.setCurrentItem(pageIndex);
}
//-----------------------------------------------------------------------------
// Here's what the app should do to get the currently displayed page.
public View getCurrentPage() {
return pagerAdapter.getView(mViewPager.getCurrentItem());
}
//-----------------------------------------------------------------------------
// Here's what the app should do to set the currently displayed page. "pageToShow" must
// currently be in the adapter, or this will crash.
public void setCurrentPage(View pageToShow) {
mViewPager.setCurrentItem(pagerAdapter.getItemPosition(pageToShow), true);
}
答案 0 :(得分:0)
render_sync
}