Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java.lang.RuntimeException:二进制XML文件第24行:膨胀类片段时出错_Java_Android_Xml_Android Fragments - Fatal编程技术网

java.lang.RuntimeException:二进制XML文件第24行:膨胀类片段时出错

java.lang.RuntimeException:二进制XML文件第24行:膨胀类片段时出错,java,android,xml,android-fragments,Java,Android,Xml,Android Fragments,我的应用程序出现以下错误 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.svpino.longhorn/com.appc.longhorn.activities.DashboardActivity}: android.view.InflateException: Binary XML file line #24: Error inflating class fragment 当我在安卓4.3中运

我的应用程序出现以下错误

java.lang.RuntimeException: Unable to start activity 
ComponentInfo{com.svpino.longhorn/com.appc.longhorn.activities.DashboardActivity}: 
android.view.InflateException: Binary XML file line #24: Error inflating class fragment
当我在安卓4.3中运行该应用程序时,它运行良好,所有内容都正确加载。然而,在4.4.2版上,它崩溃了。此外,在CM 4.4.2上的Galaxy note 3上,它运行良好

我的问题是这个设备相关的错误?从stacktrace上看,它看起来不像

我的XML

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/containerLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<fragment
    android:id="@+id/stockListFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="com.appc.longhorn.fragments.StockListFragment" />

</RelativeLayout>
您有一个IndexOutOfBounds异常

原因:java.lang.IndexOutOfBoundsException:索引0无效,大小 是0 位于java.util.ArrayList.throwIndexOutOfBoundsExceptionArrayList.java:255 位于java.util.ArrayList.getArrayList.java:308 位于com.svpino.longhorn.artifacts.StockTileProcessor.createFixedHeaderRowStockTileProcessor.java:119


建议您查看StockTileProcessor类中的第119行

尝试将android:class更改为android:name并重新测试。否仍然返回相同的错误。第24行是您能否提供完整的stacktrace?您需要查看此错误:原因:java.lang.IndexOutOfBoundsException:索引0无效,com.svpino.longhorn.artifacts.StockTileProcessor.createFixedHeaderRowStockTileProcessor.java上的大小为0:119第119行的StockTileProcessor中有错误,这是我的第119行View tile1=createTilefragment,stocks.get0,0,false;View tile2=createTilefragment,stocks.get1,1,false;View tile3=createTilefragment,stocks.get2,2,false;你一行有这么多东西?无论如何,我怀疑列表中没有任何stocks,您正在尝试获取stocks.get0中的第一个元素,而不检查它是否为空。或者只有2项,这就是stocks.get2抛出异常的原因。很抱歉,这是接下来的三行。让我通过添加null语句进行验证
public class DashboardActivity extends FragmentActivity implements StockListFragmentCallback, StockQuoteCollectorObserver {

private final static String LOG_TAG = DashboardActivity.class.getName();

private BackStack backStack;
private Dialog searchDialog;
private Dialog noConnectivityDialog;
private Dialog termsAndConditionsDialog;
private StockListFragment stockListFragment;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (Extensions.isPriorHoneycomb()) {
        requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    }

    setContentView(R.layout.activity_dashboard);