hey guys i want to display a map on the click of a button...for this i have implemented 2 classes.one class has a button and an intent call,while the second class displays the map.On running the application the button is getting displayed but on clicking it the application crashes. onclick.java
public class onclick extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btnOpen = (Button) findViewById(R.id.btnSave);
btnOpen.setOnClickListener(new View.OnClickListener() {
public void开发者_运维技巧 onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent=new Intent(onclick.this,a.class);
startActivity(myIntent);
}
});
}
}
a.java
package com.onclick;
public class a extends MapActivity{
private MapView mapView;
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.f);
mapView = (MapView)findViewById(R.id.map_view);
mapView.setStreetView(true);
}
}
In AndroidManifest.xml i have provided the internet permission,also used com.google.android.maps and the statement <activity android:name=".a"></activity>
guys plzz help me out...any help will be really appreciated
my logcat error 03-06 16:22:41.812: ERROR/AndroidRuntime(219): Uncaught handler: thread main exiting due to uncaught exception
03-06 16:22:41.883: ERROR/AndroidRuntime(219): java.lang.NoClassDefFoundError: com.onclick.a
03-06 16:22:41.883: ERROR/AndroidRuntime(219):at com.onclick.onclick$1.onClick(onclick.java:22)
03-06 16:22:41.883: ERROR/AndroidRuntime(219):at android.view.View.performClick(View.java:2364)
03-06 16:22:41.883: ERROR/AndroidRuntime(219)at android.view.View.onTouchEvent(View.java:4179) 03-06 16:22:41.883: ERROR/AndroidRuntime(219): at android.widget.TextView.onTouchEvent(TextView.java:6540)
03-06 16:22:41.883: ERROR/AndroidRuntime(219): at android.view.View.dispatchTouchEvent(View.java:3709)
03-06 16:22:41.883: ERROR/AndroidRuntime(219):at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
03-06 16:22:41.883: ERROR/AndroidRuntime(219): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
03-06 16:22:41.883: ERROR/AndroidRuntime(219):at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
03-06 16:22:41.883: ERROR/AndroidRuntime(219):at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
03-06 16:22:41.883: ERROR/AndroidRuntime(219):at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
03-06 16:22:41.883: ERROR/AndroidRuntime(219):at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
03-06 16:22:41.883: ERROR/AndroidRuntime(219):at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
03-06 16:22:41.883: ERROR/AndroidRuntime(219):at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
03-06 16:22:41.883: ERROR/AndroidRuntime(219): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
03-06 16:22:41.883: ERROR/AndroidRuntime(219): at android.os.Handler.dispatchMessage(Handler.java:99)
03-06 16:22:41.883: ERROR/AndroidRuntime(219): at android.os.Looper.loop(Looper.java:123)
03-06 16:22:41.883: ERROR/AndroidRuntime(219): at android.app.ActivityThread.main(ActivityThread.java:4363)
03-06 16:22:41.883: ERROR/AndroidRuntime(219): at java.lang.reflect.Method.invokeNative(Native Method)
03-06 16:22:41.883: ERROR/AndroidRuntime(219):at java.lang.reflect.Method.invoke(Method.java:521)
03-06 16:22:41.883: ERROR/AndroidRuntime(219): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
03-06 16:22:41.883: ERROR/AndroidRuntime(219):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
03-06 16:22:41.883: ERROR/AndroidRuntime(219):at dalvik.system.NativeStart.main(Native Method)
Make sure your package name is correct in your manifest and in all the java fils
精彩评论