gpt4 book ai didi

安卓工作室 “Button Tapped!”

转载 作者:行者123 更新时间:2023-11-30 01:47:03 27 4
gpt4 key购买 nike

<分区>

感谢您阅读这个问题。

我刚开始学习为 Android 开发应用程序,编码经验几乎为零。我正在参加的类(class)的讲师使用以下代码将添加到我们的 Android Studio 项目的按钮发送消息“Button Tapped!”每次单击特定按钮时,在日志中记录特定按钮的单击:

public void clickfunction(View view){Log.i(“Info”, “Button Tapped!”);}

我花了两天时间才在运行 OS X 10.11.1 且安装了最新更新的 iMac 上安装了 Android Studio 1.4.1 以启动 Android 模拟器。

即便如此,当使用自定义的 Android 虚拟设备 (AVD) 在已启动的模拟器中单击该按钮时,“Android 应用程序我的应用程序测试”已停止,该按钮配置为 8 英寸 DROID TURBO,内存为 3GB,分辨率为 1440 x 2560. 至少日志显示以下错误,所以从技术上讲,“按钮有效”,因为它将以下消息发送到日志。它不显示“点击按钮!”在日志中。:

安卓显示器

11-06 11:23:39.600 3298-3298/com.example.chris.myapplicationtest     E/AndroidRuntime: FATAL EXCEPTION: main
11-06 11:23:39.600 3298-3298/com.example.chris.myapplicationtest E/AndroidRuntime: Process: com.example.chris.myapplicationtest, PID: 3298
11-06 11:23:39.600 3298-3298/com.example.chris.myapplicationtest E/AndroidRuntime: java.lang.IllegalStateException: Could not find method clickfunctio(View) in a parent or ancestor Context for android:onClick attribute defined on view class android.support.v7.widget.AppCompatButton with id 'button'
11-06 11:23:39.600 3298-3298/com.example.chris.myapplicationtest E/AndroidRuntime: at android.support.v7.internal.app.AppCompatViewInflater$DeclaredOnClickListener.resolveMethod(AppCompatViewInflater.java:310)
11-06 11:23:39.600 3298-3298/com.example.chris.myapplicationtest E/AndroidRuntime: at android.support.v7.internal.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:269)
11-06 11:23:39.600 3298-3298/com.example.chris.myapplicationtest E/AndroidRuntime: at android.view.View.performClick(View.java:5198)
11-06 11:23:39.600 3298-3298/com.example.chris.myapplicationtest E/AndroidRuntime: at android.view.View$PerformClick.run(View.java:21147)
11-06 11:23:39.600 3298-3298/com.example.chris.myapplicationtest E/AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:739)
11-06 11:23:39.600 3298-3298/com.example.chris.myapplicationtest E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95)
11-06 11:23:39.600 3298-3298/com.example.chris.myapplicationtest E/AndroidRuntime: at android.os.Looper.loop(Looper.java:148)
11-06 11:23:39.600 3298-3298/com.example.chris.myapplicationtest E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417)
11-06 11:23:39.600 3298-3298/com.example.chris.myapplicationtest E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
11-06 11:23:39.600 3298-3298/com.example.chris.myapplicationtest E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
11-06 11:23:39.600 3298-3298/com.example.chris.myapplicationtest E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
11-06 11:23:41.390 3298-3298/com.example.chris.myapplicationtest I/Process: Sending signal. PID: 3298 SIG: 9

事件日志

11:00:17 AM Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:assembleDebug]
11:00:19 AM Gradle build finished with 10 error(s) in 1s 984ms
11:09:02 AM Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:assembleDebug]
11:09:03 AM Gradle build finished with 2 error(s) in 1s 426ms
11:09:26 AM Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:assembleDebug]
11:09:40 AM Gradle build finished in 14s 275ms
11:21:02 AM Session 'app': running
11:23:38 AM IllegalStateException: no segments available. offset = 3921
11:23:38 AM Platform and Plugin Updates: The following component is ready to update: Android Auto Desktop Head Unit emulator
11:23:46 AM IllegalStateException: no segments available. offset = 3654
11:26:26 AM Can't bind to local 8700 for debugger
11:26:28 AM Can't bind to local 8700 for debugger

再次,

感谢您的宝贵时间!

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com