这是我尝试使用按钮打开地图 activity 时出现的错误?
This is the error I got when I try to open a map activity with a button?
这是 logcat...
中的错误
02-29 16:01:35.490 9677-9677/com.example.deepaks.toggleswitch E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.deepaks.toggleswitch, PID: 9677
java.lang.IllegalStateException: Could not find method onbuttonclick(View) in a parent or ancestor Context for android:onClick attribute defined on view class android.support.v7.widget.AppCompatButton with id 'Alert'
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.resolveMethod(AppCompatViewInflater.java:307)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:266)
at android.view.View.performClick(View.java:4785)
at android.view.View$PerformClick.run(View.java:19884)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
我用来打开activity
的代码
public void onbutttonclick(View s)
{
if (s.getId()==R.id.Alert)
{
Intent q= new Intent(toggle.this, MapsActivity.class);
startActivity(q);
}
}
你有一个错误:
onbutttonclick
太多了"t"
你需要做
onbuttonclick
java.lang.IllegalStateException: 找不到方法 onbuttonclick(View)
你的函数是
public void onbutttonclick(View s)
它在函数定义中多了一个t。将其更改为:-
public void onbuttonclick(View s)
点击事件有错误,
只需简单地使用 onbuttonclick() 即可。
这是 logcat...
中的错误02-29 16:01:35.490 9677-9677/com.example.deepaks.toggleswitch E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.deepaks.toggleswitch, PID: 9677
java.lang.IllegalStateException: Could not find method onbuttonclick(View) in a parent or ancestor Context for android:onClick attribute defined on view class android.support.v7.widget.AppCompatButton with id 'Alert'
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.resolveMethod(AppCompatViewInflater.java:307)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:266)
at android.view.View.performClick(View.java:4785)
at android.view.View$PerformClick.run(View.java:19884)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
我用来打开activity
的代码public void onbutttonclick(View s)
{
if (s.getId()==R.id.Alert)
{
Intent q= new Intent(toggle.this, MapsActivity.class);
startActivity(q);
}
}
你有一个错误:
onbutttonclick
太多了"t"
你需要做
onbuttonclick
java.lang.IllegalStateException: 找不到方法 onbuttonclick(View)
你的函数是
public void onbutttonclick(View s)
它在函数定义中多了一个t。将其更改为:-
public void onbuttonclick(View s)
点击事件有错误, 只需简单地使用 onbuttonclick() 即可。