使用Google Map Api在Android平台上开发地图应用2

本文介绍如何在Android应用中实现新建跟踪界面的跳转与布局设计,包括Activity的创建及xml布局文件的具体代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 
1.新建跟踪界面跳转,从主界面跳转到新建跟踪的编辑界面,就要用到Activity的跳转

新建NewTrack类 ,并且创建它的xml布局文件具体代码如下:

 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
	android:orientation="vertical" android:layout_width="fill_parent"
	android:layout_height="fill_parent">

    <!-- 跟踪界面和名字 -->
	<TextView android:layout_width="fill_parent"
		android:layout_height="wrap_content" 
		android:text="@string/new_tips" />

     <!-- 跟踪名 -->
	<TextView android:layout_width="fill_parent"
		android:layout_height="wrap_content" 
		android:text="@string/new_name" />
		
		<!--编辑框-->
	<EditText android:id="@+id/new_name" 
	android:layout_width="fill_parent"
		android:layout_height="wrap_content" 
		android:text="" />
		
		<!-- 跟踪描述 -->
	<TextView android:layout_width="fill_parent"
		android:layout_height="wrap_content" 
		android:text="@string/new_desc" />
		
		<!-- 编辑框,描述 -->
	<EditText android:id="@+id/new_desc"
		android:layout_width="fill_parent" 
		android:layout_height="wrap_content"
		android:layout_weight="1"
		android:scrollbars="vertical"/>
		
		<!-- 提交按钮 -->
	<Button android:id="@+id/new_submit" 
		android:layout_width="wrap_content"
		android:layout_height="wrap_content" 
		android:text="@string/new_submit" />

</LinearLayout>


上面的布局用到了一些string 在string.xml中给于声明如下:

 

    <!-- 新增跟踪界面 -->
    <string name="new_tips">输入跟踪的名字和一段描述</string>
    <string name="new_name">跟踪名:</string>
    <string name="new_desc">跟踪描述:</string>
    <string name="new_submit">确定</string>
    <string name="new_name_null">跟踪名不能为空.</string>
    <string name="new_fail">新建跟踪失败.</string>


NewTrack类只要显示布局界面就可以,数据和按钮的处理在后面统一处理

即只在这个类中onCreate(Bundle savedInstanceState)加下面两句就可以

		setContentView(R.layout.new_track);  //设置屏幕显示
		setTitle(R.string.menu_new);      //标题显示新建跟踪

 

效果如下图:

 

新的Activity类要在androidmanifest.xml添加一句  <activity android:name="NewTrack"></activity> ,后面每个Activity都需要这样做。下一篇是复杂一点的个人设置界面

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值