C# 显示继承接口 -- 由ImageButton:IButtonControl 想到的

本文解析了显式继承的概念及在ImageButton类中如何隐含继承IButtonControl接口的Text属性。探讨了如何通过接口调用该属性,并解释了这样做在实际应用中的意义。

IButtonControl 里面又个属性叫Text, 而ImageButton继承IButtonControl ,但是ImageButton里面却没有Text 属性, 原因是ImageButton显示继承了IButtonControl 的Text 属性.

ImageButton:IButtonControl 

{
    
//此处不能使用任何修饰符
    IButtonControl.Text
    
{
         
get
         
{}
          
set
         
{}
           }

   ........
}

这里要注意的是显式继承的时候不能添加任何修饰符(例如public ,protected, private), 查看生成的dll的时候可以发现默认的前面的修饰符是protected virtual.

(1)如何使用显式继承的属性?

把ImageButton转化成IButtonControl然后再通过IButtonControl使用这个属性

IButtonControl currentButtonControl = imageButtonTest as IButtonControl;
currentButtonControl.Text 
= "I am a good baby!";

(2)ImageButton中看不到Text属性, 我们通过接口修改属性后有什么作用.

因为ImageButton中显示图片,所以不需要显示文本, 但是ImageButton有AlternateText属性, 就是用来在不能显示图片的时候显示的文本.所以下面的代码和上面的执行效果相同.

 imageButtonTest.AlternateText = "I am a good baby!";

(3) 显示继承的作用

  A, 隐藏属性(方法)

  B, 避免冲突. 当子类中已经有同名方法时候使用.

2025-09-03 20:41:06.091 718-744 AppHibernationService system_server E Package com.example.myapplication is not installed for user 0 2025-09-03 20:41:06.091 718-744 AppHibernationService system_server E Package com.example.myapplication is not installed for any user 2025-09-03 20:41:06.091 718-744 AppHibernationService system_server E Package com.example.myapplication is not installed for user 0 2025-09-03 20:41:06.091 718-744 AppHibernationService system_server E Package com.example.myapplication is not installed for any user 2025-09-03 20:48:07.905 718-858 InputDispatcher system_server E channel 'e438984 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-03 20:48:23.392 718-858 InputDispatcher system_server E channel '3a68b4d com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-03 20:49:55.365 718-858 InputDispatcher system_server E channel '5f148eb com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-03 20:50:49.872 718-858 InputDispatcher system_server E channel 'c3204c4 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-03 20:51:07.596 718-858 InputDispatcher system_server E channel '32c4c88 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-03 20:51:29.776 718-858 InputDispatcher system_server E channel '26b31b2 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-03 20:52:59.612 718-858 InputDispatcher system_server E channel '95aa8f8 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-03 20:54:02.033 718-858 InputDispatcher system_server E channel '6a720b8 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-03 21:00:20.868 718-858 InputDispatcher system_server E channel '207de1e com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-03 21:05:38.221 718-858 InputDispatcher system_server E channel 'c1f632b com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-07 20:44:52.229 1830-1942 .apps.wellbeing com.google.android.apps.wellbeing E Failed to open APK '/data/app/~~dJ88ZxVdANwbzdqaLfO8BA==/com.example.myapplication-Oci8KYGLbCHl-jUio4U6EQ==/base.apk': I/O error 2025-09-07 20:44:52.232 1830-1942 .apps.wellbeing com.google.android.apps.wellbeing E Failed to open APK '/data/app/~~dJ88ZxVdANwbzdqaLfO8BA==/com.example.myapplication-Oci8KYGLbCHl-jUio4U6EQ==/base.apk': I/O error 2025-09-07 20:44:52.232 1830-1942 ResourcesManager com.google.android.apps.wellbeing E failed to add asset path '/data/app/~~dJ88ZxVdANwbzdqaLfO8BA==/com.example.myapplication-Oci8KYGLbCHl-jUio4U6EQ==/base.apk' java.io.IOException: Failed to load asset path /data/app/~~dJ88ZxVdANwbzdqaLfO8BA==/com.example.myapplication-Oci8KYGLbCHl-jUio4U6EQ==/base.apk at android.content.res.ApkAssets.nativeLoad(Native Method) at android.content.res.ApkAssets.<init>(ApkAssets.java:322) at android.content.res.ApkAssets.loadFromPath(ApkAssets.java:171) at android.app.ResourcesManager.loadApkAssets(ResourcesManager.java:618) at android.app.ResourcesManager$ApkAssetsSupplier.load(ResourcesManager.java:287) at android.app.ResourcesManager.createAssetManager(ResourcesManager.java:714) at android.app.ResourcesManager.createResourcesImpl(ResourcesManager.java:801) at android.app.ResourcesManager.findOrCreateResourcesImplForKeyLocked(ResourcesManager.java:854) at android.app.ResourcesManager.createResources(ResourcesManager.java:1199) at android.app.ResourcesManager.getResources(ResourcesManager.java:1301) at android.app.ActivityThread.getTopLevelResources(ActivityThread.java:2979) at android.app.ApplicationPackageManager.getResourcesForApplication(ApplicationPackageManager.java:2154) at android.app.ApplicationPackageManager.getResourcesForApplication(ApplicationPackageManager.java:2140) at android.app.ApplicationPackageManager.getText(ApplicationPackageManager.java:2481) at android.content.pm.PackageItemInfo.loadUnsafeLabel(PackageItemInfo.java:237) at android.content.pm.PackageItemInfo.loadLabel(PackageItemInfo.java:226) at android.app.ApplicationPackageManager.getApplicationLabel(ApplicationPackageManager.java:2526) at cut.c(PG:38) at cfv.apply(PG:391) at e$$ExternalSyntheticApiModelOutline1.m(D8$$SyntheticClass:47) at lcx.accept(PG:44) at j$.util.stream.M0.accept(SourceFile:3) at j$.util.D.x(SourceFile:24) at j$.util.T.forEachRemaining(SourceFile:24) at j$.util.stream.b.c(SourceFile:21) at j$.util.stream.b.y(SourceFile:8) at j$.util.stream.F.b(SourceFile:5) at j$.util.stream.b.f(SourceFile:35) at j$.util.stream.c1.collect(SourceFile:83) at bva.a(PG:99) at kbp.a(PG:301) at kbp.a(PG:38) at ltp.a(PG:3) at lsv.run(PG:19) at ltr.run(PG:5) at lrz.run(PG:17) at idd.run(PG:3) at loz.run(PG:50) at hsu.run(PG:768) at java.lang.Thread.run(Thread.java:1119) at ieo.run(PG:63) 2025-09-07 20:47:00.731 718-858 InputDispatcher system_server E channel 'd671972 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-07 20:52:16.888 718-858 InputDispatcher system_server E channel '54ceef5 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-10 08:19:19.039 718-858 InputDispatcher system_server E channel 'da9443c com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-10 08:28:44.520 718-858 InputDispatcher system_server E channel 'fb3dc4e com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-10 08:31:15.953 718-858 InputDispatcher system_server E channel '50c58e2 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-10 09:08:31.738 718-1763 TransitionController system_server E Set visible without transition ActivityRecord{10540855 u0 com.example.myapplication/.MainActivity t25} playing=true caller=com.android.server.wm.TaskFragment.resumeTopActivity:1629 2025-09-10 09:46:26.507 718-858 InputDispatcher system_server E channel 'dc063cb com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 08:57:50.144 718-858 InputDispatcher system_server E channel '1f6629d com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:00:15.359 718-858 InputDispatcher system_server E channel 'b8ebe12 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:08:43.780 718-858 InputDispatcher system_server E channel 'b3a4af9 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:09:46.460 718-858 InputDispatcher system_server E channel 'e65939a com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:10:18.549 718-858 InputDispatcher system_server E channel '97c3cce com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:10:20.415 718-858 InputDispatcher system_server E channel '4a4890c com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:15:34.082 718-858 InputDispatcher system_server E channel '5112bb7 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:20:13.015 718-858 InputDispatcher system_server E channel 'd3fcd81 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:21:45.786 718-858 InputDispatcher system_server E channel '83178b7 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:40:09.328 718-858 InputDispatcher system_server E channel 'b88d2d6 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-22 17:06:12.048 13959-13959 e.myapplication com.example.myapplication I Late-enabling -Xcheck:jni 2025-09-22 17:06:12.233 13959-13959 e.myapplication com.example.myapplication I Using CollectorTypeCMC GC. 2025-09-22 17:06:12.235 13959-13959 e.myapplication com.example.myapplication W Unexpected CPU variant for x86: x86_64. Known variants: atom, sandybridge, silvermont, goldmont, goldmont-plus, goldmont-without-sha-xsaves, tremont, kabylake, alderlake, default 2025-09-22 17:06:12.271 13959-13959 nativeloader com.example.myapplication D Load libframework-connectivity-tiramisu-jni.so using APEX ns com_android_tethering for caller /apex/com.android.tethering/javalib/framework-connectivity-t.jar: ok 2025-09-22 17:06:12.588 13959-13959 nativeloader com.example.myapplication D Configuring clns-9 for other apk /data/app/~~YtxlO7izXbUn7DwQyfSn6g==/com.example.myapplication-WpLJzT4veBLnMmMJCcbkmw==/base.apk. target_sdk_version=36, uses_libraries=, library_path=/data/app/~~YtxlO7izXbUn7DwQyfSn6g==/com.example.myapplication-WpLJzT4veBLnMmMJCcbkmw==/lib/x86_64:/data/app/~~YtxlO7izXbUn7DwQyfSn6g==/com.example.myapplication-WpLJzT4veBLnMmMJCcbkmw==/base.apk!/lib/x86_64, permitted_path=/data:/mnt/expand:/data/user/0/com.example.myapplication 2025-09-22 17:06:12.595 13959-13959 e.myapplication com.example.myapplication I AssetManager2(0x79d591a4c758) locale list changing from [] to [en-US] 2025-09-22 17:06:12.607 13959-13959 GraphicsEnvironment com.example.myapplication V Currently set values for: 2025-09-22 17:06:12.607 13959-13959 GraphicsEnvironment com.example.myapplication V angle_gl_driver_selection_pkgs=[] 2025-09-22 17:06:12.607 13959-13959 GraphicsEnvironment com.example.myapplication V angle_gl_driver_selection_values=[] 2025-09-22 17:06:12.607 13959-13959 GraphicsEnvironment com.example.myapplication V com.example.myapplication is not listed in per-application setting 2025-09-22 17:06:12.608 13959-13959 GraphicsEnvironment com.example.myapplication V ANGLE allowlist from config: com.dreamgames.royalmatch com.dts.freefiremax com.dxx.firenow com.gramgames.mergedragons com.ludo.king com.mojang.minecraftpe com.my.defense com.nintendo.zaka com.os.airforce com.playrix.fishdomdd.gplay io.teslatech.callbreak jp.konami.prospia net.peakgames.toonblast 2025-09-22 17:06:12.608 13959-13959 GraphicsEnvironment com.example.myapplication V com.example.myapplication is not listed in ANGLE allowlist or settings, returning default 2025-09-22 17:06:12.608 13959-13959 GraphicsEnvironment com.example.myapplication V Neither updatable production driver nor prerelease driver is supported. 2025-09-22 17:06:12.678 13959-13993 DisplayManager com.example.myapplication I Choreographer implicitly registered for the refresh rate. 2025-09-22 17:06:12.683 13959-13959 e.myapplication com.example.myapplication I AssetManager2(0x79d591a4d6f8) locale list changing from [] to [en-US] 2025-09-22 17:06:12.754 13959-13959 AppCompatDelegate com.example.myapplication D Checking for metadata for AppLocalesMetadataHolderService : Service not found 2025-09-22 17:06:12.756 13959-13959 e.myapplication com.example.myapplication I AssetManager2(0x79d591a508f8) locale list changing from [] to [en-US] 2025-09-22 17:06:12.758 13959-13993 EGL_emulation com.example.myapplication I Opening libGLESv1_CM_emulation.so 2025-09-22 17:06:12.758 13959-13993 EGL_emulation com.example.myapplication I Opening libGLESv2_emulation.so 2025-09-22 17:06:12.770 13959-13959 ashmem com.example.myapplication E Pinning is deprecated since Android Q. Please use trim or other methods. 2025-09-22 17:06:12.779 13959-13993 HWUI com.example.myapplication W Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without... 2025-09-22 17:06:12.779 13959-13993 HWUI com.example.myapplication W Failed to initialize 101010-2 format, error = EGL_SUCCESS 2025-09-22 17:06:12.846 13959-13959 CompatChangeReporter com.example.myapplication D Compat change id reported: 377864165; UID 10217; state: ENABLED 2025-09-22 17:06:12.848 13959-13959 DesktopModeFlags com.example.myapplication D Toggle override initialized to: OVERRIDE_UNSET 2025-09-22 17:06:12.917 13959-13959 HWUI com.example.myapplication W Image decoding logging dropped! 2025-09-22 17:06:12.923 13959-13959 e.myapplication com.example.myapplication I hiddenapi: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (runtime_flags=0, domain=platform, api=unsupported) from Landroidx/appcompat/widget/ViewUtils; (domain=app) using reflection: allowed 2025-09-22 17:06:12.923 13959-13959 e.myapplication com.example.myapplication I hiddenapi: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (runtime_flags=0, domain=platform, api=unsupported) from Landroidx/appcompat/widget/ViewUtils; (domain=app) using reflection: allowed 2025-09-22 17:06:13.033 13959-13959 TransactionExecutor com.example.myapplication E Failed to execute the transaction: tId:-782804407 ClientTransaction{ tId:-782804407 transactionItems=[ tId:-782804407 LaunchActivityItem{activityToken=android.os.BinderProxy@be43358,intent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 xflg=0x4 cmp=com.example.myapplication/.MainActivity },ident=184265485,info=ActivityInfo{a09354c com.example.myapplication.MainActivity},curConfig={1.0 310mcc260mnc [en_US] ldltr sw411dp w411dp h914dp 420dpi nrml long port finger qwerty/v/v dpad/v winConfig={ mBounds=Rect(0, 0 - 1080, 2400) mAppBounds=Rect(0, 0 - 1080, 2400) mMaxBounds=Rect(0, 0 - 1080, 2400) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} as.2 s.535 fontWeightAdjustment=0},overrideConfig={1.0 310mcc260mnc [en_US] ldltr sw411dp w411dp h914dp 420dpi nrml long port finger qwerty/v/v dpad/v winConfig={ mBounds=Rect(0, 0 - 1080, 2400) mAppBounds=Rect(0, 0 - 1080, 2400) mMaxBounds=Rect(0, 0 - 1080, 2400) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mActivityType=standard mAlwaysOnTop=undefined mRotation=ROTATION_0} as.2 s.2 fontWeightAdjustment=0},deviceId=0,referrer=com.android.shell,procState=2,state=null,persistentState=null,pendingResults=null,pendingNewIntents=null,sceneTransitionInfo=null,profilerInfo=null,assistToken=android.os.BinderProxy@456b8d9,shareableActivityToken=android.os.BinderProxy@615029e,activityWindowInfo=ActivityWindowInfo{isEmbedded=false, taskBounds=Rect(0, 0 - 1080, 2400), taskFragmentBounds=Rect(0, 0 - 1080, 2400)}} tId:-782804407 ResumeActivityItem{mActivityToken=android.os.BinderProxy@be43358,procState=-1,isForward=true,shouldSendCompatFakeFocus=false} tId:-782804407 Target activity: com.example.myapplication.MainActivity tId:-782804407 ] tId:-782804407 } 2025-09-22 17:06:13.034 13959-13959 AndroidRuntime com.example.myapplication D Shutting down VM 2025-09-22 17:06:13.036 13959-13959 AndroidRuntime com.example.myapplication E FATAL EXCEPTION: main Process: com.example.myapplication, PID: 13959 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication/com.example.myapplication.MainActivity}: java.lang.ClassCastException: androidx.appcompat.widget.AppCompatImageButton cannot be cast to android.widget.Button at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4280) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4467) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:222) at android.app.servertransaction.TransactionExecutor.executeNonLifecycleItem(TransactionExecutor.java:133) at android.app.servertransaction.TransactionExecutor.executeTransactionItems(TransactionExecutor.java:103) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:80) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2823) at android.os.Handler.dispatchMessage(Handler.java:110) at android.os.Looper.loopOnce(Looper.java:248) at android.os.Looper.loop(Looper.java:338) at android.app.ActivityThread.main(ActivityThread.java:9067) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:932) Caused by: java.lang.ClassCastException: androidx.appcompat.widget.AppCompatImageButton cannot be cast to android.widget.Button at com.example.myapplication.MainActivity.setButtonListeners(MainActivity.java:107) at com.example.myapplication.MainActivity.onCreate(MainActivity.java:28) at android.app.Activity.performCreate(Activity.java:9155) at android.app.Activity.performCreate(Activity.java:9133) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1521) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4262) ... 13 more 2025-09-22 17:06:13.048 13959-13959 Process com.example.myapplication I Sending signal. PID: 13959 SIG: 9 2025-09-22 17:08:38.233 14080-14080 e.myapplication com.example.myapplication I Late-enabling -Xcheck:jni 2025-09-22 17:08:38.266 14080-14080 e.myapplication com.example.myapplication I Using CollectorTypeCMC GC. 2025-09-22 17:08:38.267 14080-14080 e.myapplication com.example.myapplication W Unexpected CPU variant for x86: x86_64. Known variants: atom, sandybridge, silvermont, goldmont, goldmont-plus, goldmont-without-sha-xsaves, tremont, kabylake, alderlake, default 2025-09-22 17:08:38.408 14080-14080 nativeloader com.example.myapplication D Load libframework-connectivity-tiramisu-jni.so using APEX ns com_android_tethering for caller /apex/com.android.tethering/javalib/framework-connectivity-t.jar: ok 2025-09-22 17:08:38.470 14080-14080 nativeloader com.example.myapplication D Load /data/user/0/com.example.myapplication/code_cache/startup_agents/3fc68f17-agent.so using system ns (caller=<unknown>): ok 2025-09-22 17:08:38.464 14080-14080 re-initialized> com.example.myapplication W type=1400 audit(0.0:1899): avc: granted { execute } for path="/data/data/com.example.myapplication/code_cache/startup_agents/3fc68f17-agent.so" dev="dm-55" ino=361083 scontext=u:r:untrusted_app:s0:c217,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c217,c256,c512,c768 tclass=file app=com.example.myapplication 2025-09-22 17:08:38.484 14080-14080 e.myapplication com.example.myapplication W hiddenapi: DexFile /data/data/com.example.myapplication/code_cache/.studio/instruments-c9b0d10a.jar is in boot class path but is not in a known location 2025-09-22 17:08:38.644 14080-14080 e.myapplication com.example.myapplication W Redefining intrinsic method java.lang.Thread java.lang.Thread.currentThread(). This may cause the unexpected use of the original definition of java.lang.Thread java.lang.Thread.currentThread()in methods that have already been compiled. 2025-09-22 17:08:38.644 14080-14080 e.myapplication com.example.myapplication W Redefining intrinsic method boolean java.lang.Thread.interrupted(). This may cause the unexpected use of the original definition of boolean java.lang.Thread.interrupted()in methods that have already been compiled. 2025-09-22 17:08:38.824 14080-14080 nativeloader com.example.myapplication D Configuring clns-9 for other apk /data/app/~~YtxlO7izXbUn7DwQyfSn6g==/com.example.myapplication-WpLJzT4veBLnMmMJCcbkmw==/base.apk. target_sdk_version=36, uses_libraries=, library_path=/data/app/~~YtxlO7izXbUn7DwQyfSn6g==/com.example.myapplication-WpLJzT4veBLnMmMJCcbkmw==/lib/x86_64:/data/app/~~YtxlO7izXbUn7DwQyfSn6g==/com.example.myapplication-WpLJzT4veBLnMmMJCcbkmw==/base.apk!/lib/x86_64, permitted_path=/data:/mnt/expand:/data/user/0/com.example.myapplication 2025-09-22 17:08:38.836 14080-14080 e.myapplication com.example.myapplication I AssetManager2(0x79d591a4c758) locale list changing from [] to [en-US] 2025-09-22 17:08:38.838 14080-14080 e.myapplication com.example.myapplication I AssetManager2(0x79d591a46fd8) locale list changing from [] to [en-US] 2025-09-22 17:08:38.843 14080-14080 GraphicsEnvironment com.example.myapplication V Currently set values for: 2025-09-22 17:08:38.843 14080-14080 GraphicsEnvironment com.example.myapplication V angle_gl_driver_selection_pkgs=[] 2025-09-22 17:08:38.843 14080-14080 GraphicsEnvironment com.example.myapplication V angle_gl_driver_selection_values=[] 2025-09-22 17:08:38.843 14080-14080 GraphicsEnvironment com.example.myapplication V com.example.myapplication is not listed in per-application setting 2025-09-22 17:08:38.844 14080-14080 GraphicsEnvironment com.example.myapplication V ANGLE allowlist from config: com.dreamgames.royalmatch com.dts.freefiremax com.dxx.firenow com.gramgames.mergedragons com.ludo.king com.mojang.minecraftpe com.my.defense com.nintendo.zaka com.os.airforce com.playrix.fishdomdd.gplay io.teslatech.callbreak jp.konami.prospia net.peakgames.toonblast 2025-09-22 17:08:38.844 14080-14080 GraphicsEnvironment com.example.myapplication V com.example.myapplication is not listed in ANGLE allowlist or settings, returning default 2025-09-22 17:08:38.844 14080-14080 GraphicsEnvironment com.example.myapplication V Neither updatable production driver nor prerelease driver is supported. 2025-09-22 17:08:38.888 14080-14096 DisplayManager com.example.myapplication I Choreographer implicitly registered for the refresh rate. 2025-09-22 17:08:38.891 14080-14080 e.myapplication com.example.myapplication I AssetManager2(0x79d591a4d6f8) locale list changing from [] to [en-US] 2025-09-22 17:08:38.929 14080-14096 EGL_emulation com.example.myapplication I Opening libGLESv1_CM_emulation.so 2025-09-22 17:08:38.930 14080-14096 EGL_emulation com.example.myapplication I Opening libGLESv2_emulation.so 2025-09-22 17:08:38.959 14080-14096 HWUI com.example.myapplication W Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without... 2025-09-22 17:08:38.960 14080-14096 HWUI com.example.myapplication W Failed to initialize 101010-2 format, error = EGL_SUCCESS 2025-09-22 17:08:38.966 14080-14080 AppCompatDelegate com.example.myapplication D Checking for metadata for AppLocalesMetadataHolderService : Service not found 2025-09-22 17:08:38.967 14080-14080 e.myapplication com.example.myapplication I AssetManager2(0x79d591a50c18) locale list changing from [] to [en-US] 2025-09-22 17:08:38.979 14080-14080 ashmem com.example.myapplication E Pinning is deprecated since Android Q. Please use trim or other methods. 2025-09-22 17:08:39.036 14080-14080 CompatChangeReporter com.example.myapplication D Compat change id reported: 377864165; UID 10217; state: ENABLED 2025-09-22 17:08:39.037 14080-14080 DesktopModeFlags com.example.myapplication D Toggle override initialized to: OVERRIDE_UNSET 2025-09-22 17:08:39.101 14080-14080 HWUI com.example.myapplication W Image decoding logging dropped! 2025-09-22 17:08:39.107 14080-14080 e.myapplication com.example.myapplication I hiddenapi: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (runtime_flags=0, domain=platform, api=unsupported) from Landroidx/appcompat/widget/ViewUtils; (domain=app) using reflection: allowed 2025-09-22 17:08:39.108 14080-14080 e.myapplication com.example.myapplication I hiddenapi: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (runtime_flags=0, domain=platform, api=unsupported) from Landroidx/appcompat/widget/ViewUtils; (domain=app) using reflection: allowed 2025-09-22 17:08:39.215 14080-14080 TransactionExecutor com.example.myapplication E Failed to execute the transaction: tId:1940201582 ClientTransaction{ tId:1940201582 transactionItems=[ tId:1940201582 LaunchActivityItem{activityToken=android.os.BinderProxy@7091517,intent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 xflg=0x4 cmp=com.example.myapplication/.MainActivity },ident=36553713,info=ActivityInfo{8c6a69b com.example.myapplication.MainActivity},curConfig={1.0 310mcc260mnc [en_US] ldltr sw411dp w411dp h914dp 420dpi nrml long port finger qwerty/v/v dpad/v winConfig={ mBounds=Rect(0, 0 - 1080, 2400) mAppBounds=Rect(0, 0 - 1080, 2400) mMaxBounds=Rect(0, 0 - 1080, 2400) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} as.2 s.536 fontWeightAdjustment=0},overrideConfig={1.0 310mcc260mnc [en_US] ldltr sw411dp w411dp h914dp 420dpi nrml long port finger qwerty/v/v dpad/v winConfig={ mBounds=Rect(0, 0 - 1080, 2400) mAppBounds=Rect(0, 0 - 1080, 2400) mMaxBounds=Rect(0, 0 - 1080, 2400) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mActivityType=standard mAlwaysOnTop=undefined mRotation=ROTATION_0} as.2 s.2 fontWeightAdjustment=0},deviceId=0,referrer=com.android.shell,procState=2,state=null,persistentState=null,pendingResults=null,pendingNewIntents=null,sceneTransitionInfo=null,profilerInfo=null,assistToken=android.os.BinderProxy@a09354c,shareableActivityToken=android.os.BinderProxy@8f10995,activityWindowInfo=ActivityWindowInfo{isEmbedded=false, taskBounds=Rect(0, 0 - 1080, 2400), taskFragmentBounds=Rect(0, 0 - 1080, 2400)}} tId:1940201582 ResumeActivityItem{mActivityToken=android.os.BinderProxy@7091517,procState=-1,isForward=true,shouldSendCompatFakeFocus=false} tId:1940201582 Target activity: com.example.myapplication.MainActivity tId:1940201582 ] tId:1940201582 } 2025-09-22 17:08:39.215 14080-14080 AndroidRuntime com.example.myapplication D Shutting down VM 2025-09-22 17:08:39.218 14080-14080 AndroidRuntime com.example.myapplication E FATAL EXCEPTION: main Process: com.example.myapplication, PID: 14080 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication/com.example.myapplication.MainActivity}: java.lang.ClassCastException: androidx.appcompat.widget.AppCompatImageButton cannot be cast to android.widget.Button at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4280) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4467) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:222) at android.app.servertransaction.TransactionExecutor.executeNonLifecycleItem(TransactionExecutor.java:133) at android.app.servertransaction.TransactionExecutor.executeTransactionItems(TransactionExecutor.java:103) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:80) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2823) at android.os.Handler.dispatchMessage(Handler.java:110) at android.os.Looper.loopOnce(Looper.java:248) at android.os.Looper.loop(Looper.java:338) at android.app.ActivityThread.main(ActivityThread.java:9067) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:932) Caused by: java.lang.ClassCastException: androidx.appcompat.widget.AppCompatImageButton cannot be cast to android.widget.Button at com.example.myapplication.MainActivity.setButtonListeners(MainActivity.java:107) at com.example.myapplication.MainActivity.onCreate(MainActivity.java:28) at android.app.Activity.performCreate(Activity.java:9155) at android.app.Activity.performCreate(Activity.java:9133) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1521) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4262) ... 13 more 2025-09-22 17:08:39.227 14080-14080 Process com.example.myapplication I Sending signal. PID: 14080 SIG: 9
最新发布
09-23
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值