如何在TabActivity底下用mapview啊

山娃马小三儿 2011-03-21 04:44:53
好像mapview不能直接用在TabActivity页面上,我想做一个分页程序,其中有一个分页用来存放地图,请问该怎么显示啊
public class MobileTrack extends TabActivity {
/** Called when the activity is first created. */
private MapView mapview;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TabHost tabHost = getTabHost();
LayoutInflater.from(this).inflate(R.layout.main, tabHost.getTabContentView(), true);

//mapview=(MapView)findViewById(R.id.map);
/*TabSpec tab1;
tab1=tabHost.newTabSpec("tab1");
tab1.setIndicator("Location", getResources().getDrawable(R.drawable.location));
//Intent i1=new Intent(this.getApplicationContext(), ScrollView.class);
tab1.setContent(R.id.scrollView2);
tabHost.addTab(tab1);


TabSpec tab1;
tab1=tabHost.newTabSpec("tab1");
tab1.setIndicator("Location", getResources().getDrawable(R.drawable.location));
//Intent i1=new Intent(this.getApplicationContext(), ScrollView.class);
tab1.setContent(R.id.scrollView2);
tabHost.addTab(tab1);
*/
tabHost.addTab(tabHost.newTabSpec("Map").setIndicator("Map").setContent(new TabHost.TabContentFactory() { public View createTabContent(String arg0) { return mapview; } }));

TabSpec tab2;
tab2=tabHost.newTabSpec("tab2");
tab2.setIndicator("GPS", getResources().getDrawable(R.drawable.gps));
//Intent i1=new Intent(this.getApplicationContext(), ScrollView.class);
tab2.setContent(R.id.scrollView2);
tabHost.addTab(tab2);

TabSpec tab3;
tab3=tabHost.newTabSpec("tab3");
tab3.setIndicator("Network", getResources().getDrawable(R.drawable.network));
//Intent i1=new Intent(this.getApplicationContext(), ScrollView.class);
tab3.setContent(R.id.scrollView3);
tabHost.addTab(tab3);

TabSpec tab4;
tab4=tabHost.newTabSpec("tab4");
tab4.setIndicator("Hardware", getResources().getDrawable(R.drawable.hardware));
//Intent i1=new Intent(this.getApplicationContext(), ScrollView.class);
tab4.setContent(R.id.scrollView4);
tabHost.addTab(tab4);


网上找了一些代码,总是不行,运行报错,求高手指点
...全文
124 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
jiayisha44 2011-05-17
  • 打赏
  • 举报
回复
怎么解决的!????!!!
  • 打赏
  • 举报
回复

接分
山娃马小三儿 2011-03-26
  • 打赏
  • 举报
回复
解决了
山娃马小三儿 2011-03-21
  • 打赏
  • 举报
回复
谁给说说啊

80,472

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧