2016-01-05 76 views
-6
01-05 10:27:57.414: E/AndroidRuntime(2311): FATAL EXCEPTION: main 
01-05 10:27:57.414: E/AndroidRuntime(2311): java.lang.IllegalStateException: Could not find a method Chapter6(View) in the activity class com.example.app.Chapter for onClick handler on view class android.widget.Button 
01-05 10:27:57.414: E/AndroidRuntime(2311):  at android.view.View$1.onClick(View.java:3586) 
01-05 10:27:57.414: E/AndroidRuntime(2311):  at android.view.View.performClick(View.java:4204) 
01-05 10:27:57.414: E/AndroidRuntime(2311):  at android.view.View$PerformClick.run(View.java:17355) 
01-05 10:27:57.414: E/AndroidRuntime(2311):  at android.os.Handler.handleCallback(Handler.java:725) 
01-05 10:27:57.414: E/AndroidRuntime(2311):  at android.os.Handler.dispatchMessage(Handler.java:92) 
01-05 10:27:57.414: E/AndroidRuntime(2311):  at android.os.Looper.loop(Looper.java:137) 
01-05 10:27:57.414: E/AndroidRuntime(2311):  at android.app.ActivityThread.main(ActivityThread.java:5041) 
01-05 10:27:57.414: E/AndroidRuntime(2311):  at java.lang.reflect.Method.invokeNative(Native Method) 
01-05 10:27:57.414: E/AndroidRuntime(2311):  at java.lang.reflect.Method.invoke(Method.java:511) 
01-05 10:27:57.414: E/AndroidRuntime(2311):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
01-05 10:27:57.414: E/AndroidRuntime(2311):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 
01-05 10:27:57.414: E/AndroidRuntime(2311):  at dalvik.system.NativeStart.main(Native Method) 
01-05 10:27:57.414: E/AndroidRuntime(2311): Caused by: java.lang.NoSuchMethodException: Chapter6 [class android.view.View] 
01-05 10:27:57.414: E/AndroidRuntime(2311):  at java.lang.Class.getConstructorOrMethod(Class.java:460) 
01-05 10:27:57.414: E/AndroidRuntime(2311):  at java.lang.Class.getMethod(Class.java:915) 
01-05 10:27:57.414: E/AndroidRuntime(2311):  at android.view.View$1.onClick(View.java:3579) 
01-05 10:27:57.414: E/AndroidRuntime(2311):  ... 11 more 
01-05 10:28:03.592: E/Trace(4119): error opening trace file: No such file or directory (2) 
+4

您是否閱讀了理解錯誤?它就在那裏...... Java代碼不重要......關鍵是你在佈局中添加處理程序到點擊按鈕,但是你沒有在活動中實現處理程序...... – Selvin

+0

也讓你的方法名稱除了班級名稱以外。通常,方法名稱應該是一些操作,例如:getMyLocation()。作爲方法名稱更有意義。 – rahul

+0

public void chapter6(View v){ \t \t CopyReadAssets(); \t} – viresh

回答

0

您需要在您的活動中創建方法第6章(視圖視圖)。你已經添加處理程序來點擊xml中的按鈕。 like android:onclick = "Chapter6"

+0

我想在每個按鈕中更改pdf – viresh

+0

然後您需要創建一個方法,您需要編寫邏輯來檢查當前章節和下一章的調用方法。 然後你需要調用像android這樣的onclick 這個新方法:onclick =「handleClick」 –

+0

我想顯示網格視圖 – viresh

相關問題