当前位置: 代码迷 >> Android >> Android inflate 与 AsyncTask 有关问题
  详细解决方案

Android inflate 与 AsyncTask 有关问题

热度:403   发布时间:2016-05-01 12:35:29.0
Android inflate 与 AsyncTask 问题
现在发现一个很奇怪的问题

我有一个layout文件,需要在异步线程中inflate出来,然后发送到主线程显示,但是奇怪的是,当Activity生成后,如果马上进行inflate,就会报错,inflateexception

郁闷的是,如果先在主线程中inflate一次,那么,再在异步线程中inflate就不会有问题,好奇怪啊,现在把xml和inflate代码贴出来,望高手帮忙解答

Inflate代码
View vwDragMainOrder = layoutInflate.inflate(
R.layout.pop_drag_mainorder, null);

layout文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <RadioGroup
        android:id="@+id/et_pop_drag_mainorder_exceptiontypegroup"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:visibility="gone"
        android:orientation="horizontal" >

        <RadioButton
            android:id="@+id/et_pop_drag_mainorder_batch"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="分批货"
            android:textSize="24sp" />

        <RadioButton
            android:id="@+id/et_pop_drag_mainorder_unshippedoffload"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="未出库拉货"
            android:textSize="24sp" />

        <RadioButton
            android:id="@+id/et_pop_drag_mainorder_shippedoffload"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="已出库拉货"
            android:textSize="24sp" />
    </RadioGroup>

    <LinearLayout
        android:id="@+id/ll_pop_drag_mainorder_pcsremark"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:visibility="gone"
        android:orientation="horizontal" >

        <TextView
            android:layout_width="90dp"
            android:layout_margin="5dp"
            android:layout_height="wrap_content"
  相关解决方案