ama*_*ion 4 android nosuchmethoderror android-mapview
我正在尝试实现自定义MapView.在我的MapActivity(名为mainmap)中,我有一个扩展MapView的内部类:
private class Lmapview extends MapView{
public Lmapview(Context context, AttributeSet attrs) {
super(context, attrs);
gestures = new GestureDetector(mainmap.this, new GestureListener(this));
}
public boolean OnTouchEvent(MotionEvent event){
return gestures.onTouchEvent(event);
}
}
Run Code Online (Sandbox Code Playgroud)
我将我的main.xml格式化为查找内部类,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<view
xmlns:android="http://schemas.android.com/apk/res/android"
class="com.mondo.tbuddy.mainmap$Lmapview"
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey=*****
/>
Run Code Online (Sandbox Code Playgroud)
另外,在Androidmanifest.xml中,我有相应的<uses-library android:name="com.google.android.maps"/>条目.
当我尝试运行我的应用程序时,我在logcat中得到(除其他外):
ERROR/AndroidRuntime(14999):引起:android.view.InflateException:二进制XML文件行#2:错误膨胀类com.mondo.tbuddy.mainmap $ Lmapview
这是由我在logcat中找到的这个条目引起的:
ERROR/AndroidRuntime(14999):引起:java.lang.NoSuchMethodException:Lmapview(Context,AttributeSet)
如果我理解正确,我的应用程序崩溃,因为Android说它没有为我的自定义MapView(Lmapview类)找到合适的构造函数.然而,正如您在上面所看到的,它已被定义并且与它正在寻找的签名相匹配.
谁能给我一些见解?
谢谢.
| 归档时间: |
|
| 查看次数: |
2361 次 |
| 最近记录: |