开发者

getting View reference from Intent

开发者 https://www.devze.com 2023-01-16 00:45 出处:网络
I create a tabbed view with a list and a map, this is the code used to build the tab: tabHost = getTabHost();

I create a tabbed view with a list and a map, this is the code used to build the tab:

tabHost = getTabHost();

TabSpec tabS开发者_JAVA百科pec = tabHost.newTabSpec("tab_map");
Intent i = new Intent().setClass(this, MyMapActivity.class);
tabSpec.setIndicator("Map",
 getResources().getDrawable(android.R.drawable.ic_menu_mapmode))
 .setContent(i);
tabHost.addTab(tabSpec);

now I need to access the MapView to set some Overlay on that map but if I try to do this:

MapView mapView = (MapView) findViewById(R.id.myMap);

the reference is always null, which is the right way? Thanks!!!

-- Luca


you could use

intent.putExtra(MyMapActivity.Something, value);

depends upon where you call MapView as whether the view has been inflated yet or not..obviously if it has not been inflated yet you might get a null

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号