tabactivty中加入地图

本文介绍了一个简单的Android应用程序示例,该程序使用TabActivity实现两个视图之间的切换:地图视图和详细信息视图。文章展示了如何设置TabHost、定义TabSpec以及使用Intent进行页面跳转。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="com.kroz.tag" android:versionCode="1" android:versionName="1.0">
 <application android:icon="@drawable/icon" android:label="@string/app_name">
    <uses-library android:name="com.google.android.maps"/>
    <activity android:name=".AppMain" android:label="@string/app_name">
       <intent-filter>
           <action android:name="android.intent.action.MAIN"/>
           <category android:name="android.intent.category.LAUNCHER"/>
       </intent-filter>
    </activity>
    <activity android:name="MapTabView" android:label="@string/mapview_name">
       <intent-filter>
          <category android:name="android.intent.category.EMBED"></category>
          <action android:name="android.intent.action.MAIN"></action>
       </intent-filter>
    </activity>
  </application>
 <uses-sdk android:minSdkVersion="3"/>
 <uses-permission android:name="android.permission.INTERNET"></uses-permission>
 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
 <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"></uses-permission>
</manifest>

 这里面有两个方法 其实说来还是一样的

1.

public class BS_Main extends TabActivity { 
/** Called when the activity is first created. */ 
@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
          TabHost tabHost = getTabHost(); 
    tabHost.addTab(tabHost.newTabSpec("tab1").setContent(R.id.mapview).setIndicator("mapview_name",getResources().getDrawable(R.drawable.map_icon))); 
    tabHost.addTab(tabHost.newTabSpec("tab2").setContent(R.id.anotherview).setIndicator("tab2_name",getResources().getDrawable(R.drawable.anotherview_icon))); 
  } 
} 

 <?xml version="1.0" encoding="utf-8"?> 
<TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@android:id/tabhost" android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 
<TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="fill_parent" /> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
   
android:orientation="vertical" android:id="@android:id/tabcontent" 
   
android:layout_width="fill_parent" android:layout_height="fill_parent"> 
<mapview tag here with ur map Api key> 
<anotherview tag> 
</FrameLayout> 

 

 

2.Main.xml

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
   android:id="@android:id/tabhost"
   android:layout_width="fill_parent" android:layout_height="fill_parent">
   <LinearLayout android:orientation="vertical"
     android:layout_width="fill_parent" android:layout_height="fill_parent">
      <TabWidget android:id="@android:id/tabs"
         android:layout_width="fill_parent" android:layout_height="wrap_content"/>
      <FrameLayout android:id="@android:id/tabcontent"
         android:layout_width="fill_parent" android:layout_height="fill_parent">
          <RelativeLayout android:id="@+id/emptylayout1" android:orientation="vertical"
             android:layout_width="fill_parent" android:layout_height="fill_parent"/>
          <TextView android:id="@+id/textview2"
             android:layout_width="fill_parent"
               android:layout_height="fill_parent"
             android:text="Details Details Details Details"/>
      </FrameLayout>
   </LinearLayout>
</TabHost>

 Maptabview.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/maptablayout" android:orientation="vertical"
    android:layout_width="fill_parent" android:layout_height="fill_parent">
    <com.google.android.maps.MapView android:id="@+id/mapview"
       android:layout_width="fill_parent" android:layout_height="fill_parent"
       android:clickable="true"
        android:apiKey="0pFtdSwta8EMTfArj32ycOw2kZg0LSEqa4fUGFA"/>
</RelativeLayout>

 

package com.kroz.tag;

import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.FrameLayout;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;

public class AppMain extends TabActivity  {
 TabHost mTabHost;
 FrameLayout mFrameLayout;

 /** Called when the activity is first created.*/
 @Override
 public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    mTabHost = getTabHost();
    TabSpec tabSpec = mTabHost.newTabSpec("tab_test1");
    tabSpec.setIndicator("Map");
    Context ctx = this.getApplicationContext();
    Intent i = new Intent(ctx, MapTabView.class);
    tabSpec.setContent(i);
    mTabHost.addTab(tabSpec);
    mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("Details").setContent(R.id.textview2));
    mTabHost.setCurrentTab(0);
 }
}

 

 

package com.kroz.tag;

import android.os.Bundle;
import com.google.android.maps.MapActivity;

public class MapTabView extends MapActivity {
 @Override
 protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.maptabview);
 }
 @Override
 protected boolean isRouteDisplayed() {
   return false;
 }
}

 

 

内容概要:本文围绕EKF SLAM(扩展卡尔曼滤波同步定位与地图构建)的性能展开多项对比实验研究,重点分析在稀疏与稠密landmark环境下、预测与更新步骤同时进行与非同时进行的情况下的系统性能差异,并进一步探讨EKF SLAM在有色噪声干扰下的鲁棒性表现。实验考虑了不确定性因素的影响,旨在评估不同条件下算法的定位精度与地图构建质量,为实际应用中EKF SLAM的优化提供依据。文档还提及多智能体系统在遭受DoS攻击下的弹性控制研究,但核心内容聚焦于SLAM算法的性能测试与分析。; 适合人群:具备一定机器人学、状态估计或自动驾驶基础知识的科研人员及工程技术人员,尤其是从事SLAM算法研究或应用开发的硕士、博士研究生和相关领域研发人员。; 使用场景及目标:①用于比较EKF SLAM在不同landmark密度下的性能表现;②分析预测与更新机制同步与否对滤波器稳定性与精度的影响;③评估系统在有色噪声等非理想观测条件下的适应能力,提升实际部署中的可靠性。; 阅读建议:建议结合MATLAB仿真代码进行实验复现,重点关注状态协方差传播、观测更新频率与噪声模型设置等关键环节,深入理解EKF SLAM在复杂环境下的行为特性。稀疏 landmark 与稠密 landmark 下 EKF SLAM 性能对比实验,预测更新同时进行与非同时进行对比 EKF SLAM 性能对比实验,EKF SLAM 在有色噪声下性能实验
内容概要:本文围绕“基于主从博弈的售电商多元零售套餐设计与多级市场购电策略”展开,结合Matlab代码实现,提出了一种适用于电力市场化环境下的售电商优化决策模型。该模型采用主从博弈(Stackelberg Game)理论构建售电商与用户之间的互动关系,售电商作为领导者制定电价套餐策略,用户作为跟随者响应电价并调整用电行为。同时,模型综合考虑售电商在多级电力市场(如日前市场、实时市场)中的【顶级EI复现】基于主从博弈的售电商多元零售套餐设计与多级市场购电策略(Matlab代码实现)购电组合优化,兼顾成本最小化与收益最大化,并引入不确定性因素(如负荷波动、可再生能源出力变化)进行鲁棒或随机优化处理。文中提供了完整的Matlab仿真代码,涵盖博弈建模、优化求解(可能结合YALMIP+CPLEX/Gurobi等工具)、结果可视化等环节,具有较强的可复现性和工程应用价值。; 适合人群:具备一定电力系统基础知识、博弈论初步认知和Matlab编程能力的研究生、科研人员及电力市场从业人员,尤其适合从事电力市场运营、需求响应、售电策略研究的相关人员。; 使用场景及目标:① 掌握主从博弈在电力市场中的建模方法;② 学习售电商如何设计差异化零售套餐以引导用户用电行为;③ 实现多级市场购电成本与风险的协同优化;④ 借助Matlab代码快速复现顶级EI期刊论文成果,支撑科研项目或实际系统开发。; 阅读建议:建议读者结合提供的网盘资源下载完整代码与案例数据,按照文档目录顺序逐步学习,重点关注博弈模型的数学表达与Matlab实现逻辑,同时尝试对目标函数或约束条件进行扩展改进,以深化理解并提升科研创新能力。
内容概要:本文介绍了基于粒子群优化算法(PSO)的p-Hub选址优化问基于粒子群优化算法的p-Hub选址优化(Matlab代码实现)题的Matlab代码实现,旨在解决物流与交通网络中枢纽节点的最优选址问题。通过构建数学模型,结合粒子群算法的全局寻优能力,优化枢纽位置及分配策略,提升网络传输效率并降低运营成本。文中详细阐述了算法的设计思路、实现步骤以及关键参数设置,并提供了完整的Matlab仿真代码,便于读者复现和进一步改进。该方法适用于复杂的组合优化问题,尤其在大规模网络选址中展现出良好的收敛性和实用性。; 适合人群:具备一定Matlab编程基础,从事物流优化、智能算法研究或交通运输系统设计的研究生、科研人员及工程技术人员;熟悉优化算法基本原理并对实际应用场景感兴趣的从业者。; 使用场景及目标:①应用于物流中心、航空枢纽、快递分拣中心等p-Hub选址问题;②帮助理解粒子群算法在离散优化问题中的编码与迭代机制;③为复杂网络优化提供可扩展的算法框架,支持进一步融合约束条件或改进算法性能。; 阅读建议:建议读者结合文中提供的Matlab代码逐段调试运行,理解算法流程与模型构建逻辑,重点关注粒子编码方式、适应度函数设计及约束处理策略。可尝试替换数据集或引入其他智能算法进行对比实验,以深化对优化效果和算法差异的理解。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值