我正在制作这个项目,我需要从另一个项目中复制xml代码。 在我这样做之后,我的项目中的所有xml文件都没有显示在图形布局中。 而是写了这个警告:
java.lang.NullPointerException
Exception details are logged in Window > Show View > Error Log
当我在错误日志中查找时,我得到了。
消息:
chat_layout.xml: java.lang.NullPointerException
异常堆栈跟踪:
java.lang.NullPointerException
at android.graphics.Bitmap_Delegate.nativeWidth(Bitmap_Delegate.java:291)
at android.graphics.Bitmap.nativeWidth(Bitmap.java)
at android.graphics.Bitmap.getWidth(Bitmap.java:909)
at android.graphics.Bitmap.getScaledWidth(Bitmap.java:957)
at android.graphics.drawable.BitmapDrawable.computeBitmapSize(BitmapDrawable.java:179)
at android.graphics.drawable.BitmapDrawable.setBitmap(BitmapDrawable.java:187)
at android.graphics.drawable.BitmapDrawable.<init>(BitmapDrawable.java:555)
at android.graphics.drawable.BitmapDrawable.<init>(BitmapDrawable.java:110)
at com.android.layoutlib.bridge.impl.ResourceHelper.getDrawable(ResourceHelper.java:239)
at com.android.layoutlib.bridge.bars.CustomBar.loadIcon(CustomBar.java:196)
at com.android.layoutlib.bridge.bars.CustomBar.loadIconById(CustomBar.java:188)
at com.android.layoutlib.bridge.bars.CustomBar.loadIconById(CustomBar.java:155)
at com.android.layoutlib.bridge.bars.FakeActionBar.<init>(FakeActionBar.java:38)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:333)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:332)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:325)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.RenderService.createRenderSession(RenderService.java:440)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.renderWithBridge(GraphicalEditorPart.java:1545)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.recomputeLayout(GraphicalEditorPart.java:1302)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.activated(GraphicalEditorPart.java:1059)
at com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditorDelegate.delegatePageChange(LayoutEditorDelegate.java:683)
at com.android.ide.eclipse.adt.internal.editors.common.CommonXmlEditor.pageChange(CommonXmlEditor.java:360)
at org.eclipse.ui.part.MultiPageEditorPart$2.widgetSelected(MultiPageEditorPart.java:290)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:774)
at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:2746)
at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1433)
at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:257)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4169)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3758)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
图形布局适用于Eclipse中我的所有项目的所有其他xml文件,除此之外。在复制之前一切正常。该怎么办?
xml文件如下。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/background_dark"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/bottom_write_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<EditText
android:id="@+id/textbox"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_margin="5sp"
android:layout_weight="1"
android:hint="Write here"
android:padding="5sp"
tools:ignore="HardcodedText" />
<Button
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_margin="5sp"
android:onClick="sendMessage"
android:paddingBottom="5sp"
android:paddingLeft="15sp"
android:paddingRight="15sp"
android:paddingTop="5sp"
android:text="Send"
android:textColor="#FFF"
tools:ignore="HardcodedText" />
</LinearLayout>
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_above="@id/bottom_write_bar"
android:layout_alignParentTop="true"
android:cacheColorHint="#00000000"
android:divider="#00000000"
android:listSelector="#00000000" >
</ListView>
<TextView
android:id="@android:id/empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@id/bottom_write_bar"
android:layout_alignParentTop="true"
android:gravity="center_vertical|center_horizontal" />
</RelativeLayout>
答案 0 :(得分:2)
似乎我的应用程序使用的是不兼容的图标类型。 当我改变它的Icon类型时它起作用了。这是一个愚蠢的错误,但它让我忙碌:/
答案 1 :(得分:0)
检查来自源的所有res图像是否都在bin / res文件夹中
答案 2 :(得分:0)
你似乎有两个问题中的任何一个。
答案 3 :(得分:0)
昨天我也遇到了这个问题,我刚才解决了。只需尝试安装更低或更高的API级别Platform SDK。一开始,我希望我的应用程序可以使用旧平台,所以我用旧样式主题创建了我的程序,但是当我编辑我的xml并用4.3 SDK查看它时,我收到了这个错误。