如何解决ClassCastExeption?

时间:2019-12-09 19:59:09

标签: java android android-studio

  

您能告诉我如何解决该ClassCastExeption吗?

* java.lang.ClassCastException:com.intellij.psi.impl.source.PsiPlainTextFileImpl无法转换为com.intellij.psi.xml.XmlFile     在com.android.tools.idea.common.model.NlModel.getFile(NlModel.java:230)     在com.android.tools.idea.uibuilder.scene.LayoutlibSceneManager $ ModelChangeListener.modelActivated(LayoutlibSceneManager.java:454)     在com.android.tools.idea.common.model.NlModel.lambda $ activate $ 0(NlModel.java:184)     在java.lang.Iterable.forEach(Iterable.java:75)     在com.android.tools.idea.util.ListenerCollection $ forEach $ 1.run(ListenerCollection.kt:80)     在com.google.common.util.concurrent.MoreExecutors $ DirectExecutor.execute(MoreExecutors.java:398)     在com.android.tools.idea.util.ListenerCollection.forEach(ListenerCollection.kt:79)     在com.android.tools.idea.common.model.NlModel.activate(NlModel.java:184)     在com.android.tools.idea.common.surface.DesignSurface.activate(DesignSurface.java:925)     在com.android.tools.idea.common.editor.DesignerEditorPanel.activate(DesignerEditorPanel.java:190)     在com.android.tools.idea.common.editor.DesignerEditor.selectNotify(DesignerEditor.java:87)     在com.intellij.openapi.fileEditor.impl.EditorTabbedContainer $ 2.selectionChanged(EditorTabbedContainer.java:151)     在com.intellij.ui.tabs.impl.JBTabsImpl.fireSelectionChanged(JBTabsImpl.java:947)     在com.intellij.ui.tabs.impl.JBTabsImpl.executeSelectionChange(JBTabsImpl.java:903)     at com.intellij.ui.tabs.impl.JBTabsImpl.access $ 1900(JBTabsImpl.java:52)     在com.intellij.ui.tabs.impl.JBTabsImpl $ 9.run(JBTabsImpl.java:862)     在com.intellij.openapi.fileEditor.impl.EditorTabbedContainer.lambda $ null $ 2(EditorTabbedContainer.java:163)     在com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:220)     在com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:178)     在com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:168)     在com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:154)     在com.intellij.openapi.fileEditor.impl.EditorTabbedContainer.lambda $ new $ 3(EditorTabbedContainer.java:161)     在com.intellij.ui.tabs.impl.JBTabsImpl._setSelected(JBTabsImpl.java:858)     在com.intellij.ui.tabs.impl.JBTabsImpl.select(JBTabsImpl.java:849)     在com.intellij.ui.tabs.impl.TabLabel $ 1.mousePressed(TabLabel.java:96)     在java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:279)     在java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:279)     在java.awt.Component.processMouseEvent(Component.java:6547)     在javax.swing.JComponent.processMouseEvent(JComponent.java:3325)     在java.awt.Component.processEvent(Component.java:6315)     在java.awt.Container.processEvent(Container.java:2239)     在java.awt.Component.dispatchEventImpl(Component.java:4899)     在java.awt.Container.dispatchEventImpl(Container.java:2297)     在java.awt.Component.dispatchEvent(Component.java:4721)     在java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4904)     在java.awt.LightweightDispatcher.processMouseEvent(Container.java:4532)     在java.awt.LightweightDispatcher.dispatchEvent(Container.java:4476)     在java.awt.Container.dispatchEventImpl(Container.java:2283)     在java.awt.Window.dispatchEventImpl(Window.java:2746)     在java.awt.Component.dispatchEvent(Component.java:4721)     在java.awt.EventQueue.dispatchEventImpl(EventQueue.java:766)     在java.awt.EventQueue.access $ 500(EventQueue.java:98)     在java.awt.EventQueue $ 3.run(EventQueue.java:715)     在java.awt.EventQueue $ 3.run(EventQueue.java:709)     在java.security.AccessController.doPrivileged(本机方法)     在java.security.ProtectionDomain $ JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)     在java.security.ProtectionDomain $ JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)     在java.awt.EventQueue $ 4.run(EventQueue.java:739)     在java.awt.EventQueue $ 4.run(EventQueue.java:737)     在java.security.AccessController.doPrivileged(本机方法)     在java.security.ProtectionDomain $ JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)     在java.awt.EventQueue.dispatchEvent(EventQueue.java:736)     在com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:757)     在com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:702)     在com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:375)     在java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)     在java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)     在java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)     在java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)     在java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)     在java.awt.EventDispatchThread.run(EventDispatchThread.java:82)



>MainActivity.java:

package com.example.findyourgift;

import androidx.appcompat.app.AppCompatActivity;

导入android.os.Bundle;

公共类MainActivity扩展了AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

} *

  

activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <TextView
        android:layout_width="279dp"
        android:layout_height="101dp"
        android:fontFamily="monospace"
        android:gravity="center"
        android:text="@string/textStart"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.242" />

</androidx.constraint

0 个答案:

没有答案