android intellij 切换 nullpointerException

2024-04-04

我正在尝试将一个开关小部件放入 IntelliJ 中的活动中。 当我这样做时,设计器崩溃,并在 android.widget.Switch.jumpDrawablesToCurrentState 内出现 NullPointException 和长堆栈跟踪。

该元素添加了 android:id="@+id/switch" ,这会产生编译器错误:无效符号:'switch'

我必须将名称更改为除“switch”之外的其他名称。很奇怪看到系统添加了一个无效的名称,但好吧我可以接受。

但是当切换在布局中时,视觉设计器仍然没有用处。 我在谷歌中唯一能找到的是描述这一点的错误跟踪器条目。但没有解决办法。 那里发生了什么事?有人知道解决方案吗?

编辑 我添加堆栈跟踪:

java.lang.NullPointerException at android.widget.Switch.jumpDrawablesToCurrentState(Switch.java:825) at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5158) at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5158) at android.widget.FrameLayout.jumpDrawablesToCurrentState(FrameLayout.java:189) at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5158) at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5158) at android.view.View.onAttachedToWindow(View.java:11560) at android.view.View.dispatchAttachedToWindow(View.java:11937) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2415) at android.view.AttachInfo_Accessor.setAttachInfo(AttachInfo_Accessor.java:42) at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:393) at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:332) at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:333) at org.jetbrains.android.uipreview.RenderService.createRenderSession(RenderService.java:127) at org.jetbrains.android.uipreview.RenderUtil.renderLayout(RenderUtil.java:154) at com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel$8.run(AndroidDesignerEditorPanel.java:346) at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320) at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310) at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254) at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269) at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227) at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217) at com.intellij.util.Alarm$Request$1.run(Alarm.java:289) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722)

添加开关后,它会出现在设计器视图中,而不是活动中。


None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

android intellij 切换 nullpointerException 的相关文章

随机推荐