我在 viewpager 中有一个 Listfragment,该片段只包含
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Log.e("Starter", "Starter");
View v = inflater.inflate(R.layout.chat, container, false);
text = (EditText) v.findViewById(R.id.text);
return v;
}
chat.xml 文件包含
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="45dp" >
</ListView>
<EditText
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignTop="@+id/button1"
android:layout_toLeftOf="@+id/button1"
android:ems="10"
android:inputType="textMultiLine" >
</EditText>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="Send" />
我可以按 EditText,键盘就会出现,如果我按后退按钮,它就会消失。当键盘升起或按下时,列表视图会改变大小。
所有这一切都很好,直到我按下主页按钮,等待一两秒钟,然后再次进入应用程序。然后我收到以下错误:
我在列表中没有任何位图,也没有任何会导致此错误的内容。在您退出应用程序、重新进入并单击 EditText 之前,这一切都有效。
如果有人知道为什么会发生这种情况,很高兴收到您的来信!
04-13 14:02:06.121: E/AndroidRuntime(19976): FATAL EXCEPTION: main
04-13 14:02:06.121: E/AndroidRuntime(19976): java.lang.IllegalArgumentException: Cannot draw recycled bitmaps
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.GLES20Canvas.drawBitmap(GLES20Canvas.java:797)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.GLES20RecordingCanvas.drawBitmap(GLES20RecordingCanvas.java:117)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:393)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.widget.ImageView.onDraw(ImageView.java:1095)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.View.draw(View.java:13553)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.View.getDisplayList(View.java:12504)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.View.getDisplayList(View.java:12548)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.View.draw(View.java:13277)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.ViewGroup.drawChild(ViewGroup.java:2947)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2817)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.View.getDisplayList(View.java:12502)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.View.getDisplayList(View.java:12548)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.View.draw(View.java:13277)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.ViewGroup.drawChild(ViewGroup.java:2947)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2817)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.View.draw(View.java:13556)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.widget.FrameLayout.draw(FrameLayout.java:467)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.widget.ScrollView.draw(ScrollView.java:1562)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.View.getDisplayList(View.java:12504)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.View.getDisplayList(View.java:12548)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.View.draw(View.java:13277)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.ViewGroup.drawChild(ViewGroup.java:2947)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2817)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.View.getDisplayList(View.java:12502)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.View.getDisplayList(View.java:12548)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.View.draw(View.java:13277)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.ViewGroup.drawChild(ViewGroup.java:2947)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2817)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.View.getDisplayList(View.java:12502)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.View.getDisplayList(View.java:12548)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2929)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.View.getDisplayList(View.java:12440)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.View.getDisplayList(View.java:12548)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2929)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.View.getDisplayList(View.java:12440)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.View.getDisplayList(View.java:12548)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2929)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.View.getDisplayList(View.java:12440)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.View.getDisplayList(View.java:12548)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2929)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.View.getDisplayList(View.java:12440)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.View.getDisplayList(View.java:12548)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1170)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.ViewRootImpl.draw(ViewRootImpl.java:2432)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2286)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2053)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1151)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4661)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.Choreographer.doCallbacks(Choreographer.java:555)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.Choreographer.doFrame(Choreographer.java:525)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.os.Handler.handleCallback(Handler.java:615)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.os.Handler.dispatchMessage(Handler.java:92)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.os.Looper.loop(Looper.java:155)
04-13 14:02:06.121: E/AndroidRuntime(19976): at android.app.ActivityThread.main(ActivityThread.java:5493)
04-13 14:02:06.121: E/AndroidRuntime(19976): at java.lang.reflect.Method.invokeNative(Native Method)
04-13 14:02:06.121: E/AndroidRuntime(19976): at java.lang.reflect.Method.invoke(Method.java:511)
04-13 14:02:06.121: E/AndroidRuntime(19976): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028)
04-13 14:02:06.121: E/AndroidRuntime(19976): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:795)
04-13 14:02:06.121: E/AndroidRuntime(19976): at dalvik.system.NativeStart.main(Native Method)