我想在 android 的 mapview 上方添加编辑文本,所以我创建了这个布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:id="@+id/base">
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:id="@+id/zoomtext"
>
</EditText>
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="myAPIkey"
android:layout_below="@+id/zoomtext"/>
</RelativeLayout>
这是我的java代码
package zoom.map;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import android.os.Bundle;
import android.widget.EditText;
public class ZoomapActivity extends MapActivity {
EditText zoombtn;
int angkazoom;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MapView mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
zoombtn = (EditText) findViewById(R.id.zoomtext);
angkazoom = mapView.getZoomLevel();
zoombtn.setText(angkazoom);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
这是我的错误日志猫
04-18 13:08:37.230: E/AndroidRuntime(309): FATAL EXCEPTION: main
04-18 13:08:37.230: E/AndroidRuntime(309): java.lang.RuntimeException: Unable to start activity ComponentInfo{zoom.map/zoom.map.ZoomapActivity}: android.content.res.Resources$NotFoundException: String resource ID #0x3
04-18 13:08:37.230: E/AndroidRuntime(309): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-18 13:08:37.230: E/AndroidRuntime(309): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-18 13:08:37.230: E/AndroidRuntime(309): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-18 13:08:37.230: E/AndroidRuntime(309): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-18 13:08:37.230: E/AndroidRuntime(309): at android.os.Handler.dispatchMessage(Handler.java:99)
04-18 13:08:37.230: E/AndroidRuntime(309): at android.os.Looper.loop(Looper.java:123)
04-18 13:08:37.230: E/AndroidRuntime(309): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-18 13:08:37.230: E/AndroidRuntime(309): at java.lang.reflect.Method.invokeNative(Native Method)
04-18 13:08:37.230: E/AndroidRuntime(309): at java.lang.reflect.Method.invoke(Method.java:521)
04-18 13:08:37.230: E/AndroidRuntime(309): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-18 13:08:37.230: E/AndroidRuntime(309): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-18 13:08:37.230: E/AndroidRuntime(309): at dalvik.system.NativeStart.main(Native Method)
04-18 13:08:37.230: E/AndroidRuntime(309): Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x3
04-18 13:08:37.230: E/AndroidRuntime(309): at android.content.res.Resources.getText(Resources.java:201)
04-18 13:08:37.230: E/AndroidRuntime(309): at android.widget.TextView.setText(TextView.java:2817)
04-18 13:08:37.230: E/AndroidRuntime(309): at zoom.map.ZoomapActivity.onCreate(ZoomapActivity.java:21)
04-18 13:08:37.230: E/AndroidRuntime(309): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-18 13:08:37.230: E/AndroidRuntime(309): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-18 13:08:37.230: E/AndroidRuntime(309): ... 11 more
我不知道出了什么问题..布局没有问题,我在通过stackoverflow搜索的java中没有错误,但还没有找到答案..