use*_*659 5 google-maps-android-api-2
今天我已经阅读了谷歌地图Android API v2的文档,它说该项目android-sdk\extras\google\google_play_services\samples\maps可以运行,但是我导入到eclipse并正确设置了android-support-v4.jargoogle-play-services.jar 的库,import com.example.mapdemo.R;在FeatureView.java(第24行)不能找到文件R.java.
几乎所有的java文件都com.example.mapdemo需要类"R",例如,文件BasicMapActivity.java需要R在第41行" setContentView(R.layout.basic_demo);"和第71行mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();"有人能告诉我如何找到类"R"吗?
[R
.java can not create automatically because the file multimap_demo.xml have some errors in
<br><br> <fragment
<br> android:id="@+id/map3"
<br> android:layout_width="match_parent"
<br> android:layout_height="match_parent"
<br> android:layout_weight="0.5"
<br> class="com.google.android.gms.maps.SupportMapFragment"
<br> map:cameraTargetLat="48.85"
<br> map:cameraTargetLng="2.35"
<br> map:cameraZoom="8"/>
<br><br>
Run Code Online (Sandbox Code Playgroud)
eclipse说"cameraTargetLat","cameraTargetLng"和"cameraZoom"都无法识别.错误信息:
Multiple annotations found at this line:
- error: No resource identifier found for attribute 'cameraTargetLat' in package 'com.example.mapdemo'
- error: No resource identifier found for attribute 'cameraTargetLng' in package 'com.example.mapdemo'
- error: No resource identifier found for attribute 'cameraZoom' in package 'com.example.mapdemo'
I do not know why.
If I change the code like this:
<br><br> <fragment
<br> android:id="@+id/map3"
<br> android:layout_width="match_parent"
<br> android:layout_height="match_parent"
<br> android:layout_weight="0.5"
<br> class="com.google.android.gms.maps.SupportMapFragment"/>
<br><br>
Run Code Online (Sandbox Code Playgroud)
错误消失了,但我不知道它是否可以运行.
小智 -1
您必须xmlns:map="http://schemas.android.com/apk/res-auto"在布局 xml 中包含才能使用map元素。
R 文件是由 Eclipse自动生成的,您可以在gen目录中找到它。永远不要编辑此文件!在某些情况下,您会发现有多个 R 文件,例如当您向项目添加库时,例如google-play-services_lib. 您始终可以通过这样的代码引用该文件...
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(com.your.package.R.id.map)).getMap();
Run Code Online (Sandbox Code Playgroud)
如果您想配置地图,可以通过XML 属性或以编程方式进行配置。
| 归档时间: |
|
| 查看次数: |
10607 次 |
| 最近记录: |