Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/182.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
android中的运行时异常_Android_Exception_Runtime_Classcastexception - Fatal编程技术网

android中的运行时异常

android中的运行时异常,android,exception,runtime,classcastexception,Android,Exception,Runtime,Classcastexception,布局文件启动活动 {com.androidbook.triviaquiz/com.androidbook.triviaquiz.QuizSplashActivity}: java.lang.ClassCastException: android.widget.TextView 嗯,一切看起来都很好。但我还是希望你检查两个地方: 确保布局的文件名确实是splash 如果以前将其他内容命名为textView1或textView2,则可能需要清理项目并从头开始重建 请将整个异常粘贴到发生异常的那一行

布局文件启动活动

{com.androidbook.triviaquiz/com.androidbook.triviaquiz.QuizSplashActivity}: java.lang.ClassCastException: android.widget.TextView

嗯,一切看起来都很好。但我还是希望你检查两个地方:

  • 确保布局的文件名确实是splash
  • 如果以前将其他内容命名为textView1或textView2,则可能需要清理项目并从头开始重建

  • 请将整个异常粘贴到发生异常的那一行。编辑que并使其更易于理解只需查看堆栈跟踪并找出发生异常的那一行。最有可能的是,在你发现之后,你自己也能找到这个bug。
    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.androidbook.triviaquiz"
          android:versionCode="1"
          android:versionName="1.0">
        <uses-sdk android:minSdkVersion="7" />
    
        <application android:icon="@drawable/quizicon" android:label="@string/app_name" android:debuggable="true">
          <activity android:name=".QuizSplashActivity" android:label="@string/splash">
               <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
            <activity android:name="QuizGameActivty" android:label="@string/game"></activity>
            <activity android:name="QuizHelpActivity" android:label="@string/help"></activity>
            <activity android:name="QuizMenuActivity" android:label="@string/menu"></activity>
            <activity android:name="QuizScoresActivity" android:label="@string/scores"></activity>
            <activity android:name="QuizsettingsActivity" android:label="@string/settings"></activity>
    
        </application>
    
    </manifest>
    
    {com.androidbook.triviaquiz/com.androidbook.triviaquiz.QuizSplashActivity}: java.lang.ClassCastException: android.widget.TextView
    
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:weightSum="1">
        <LinearLayout android:layout_width="fill_parent" android:id="@+id/linearLayout1" android:layout_height="wrap_content" android:orientation="vertical" android:background="@android:color/black" android:layout_weight="0.94" android:weightSum="1">
            <TextView android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_weight="0.08" android:text="@string/header" android:textColor="@color/logo_color" android:textSize="24pt" android:id="@+id/textView1"></TextView>
            <TableLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/tableLayout1" android:layout_weight="0.48" android:weightSum="1" android:stretchColumns="*">
                <TableRow android:id="@+id/tableRow1" android:layout_height="wrap_content" android:layout_width="fill_parent">
                    <ImageView android:src="@drawable/splash1" android:id="@+id/imageView1" android:layout_height="wrap_content" android:layout_width="fill_parent"></ImageView>
                    <ImageView android:src="@drawable/splash2" android:id="@+id/imageView2" android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageView>
                </TableRow>
                <TableRow android:id="@+id/tableRow2" android:layout_height="wrap_content" android:layout_width="fill_parent">
                    <ImageView android:src="@drawable/splash3" android:id="@+id/imageView3" android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageView>
                    <ImageView android:src="@drawable/splash4" android:id="@+id/imageView4" android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageView>
                </TableRow>
                <TextView android:layout_height="wrap_content" android:id="@+id/textView2" android:layout_width="fill_parent" android:textColor="@color/logo_color" android:fadeScrollbars="true" android:focusableInTouchMode="true" android:textSize="24pt" android:text="@string/footer" android:layout_weight="0.36"></TextView>
                </TableLayout>
            <TextView android:layout_width="fill_parent" android:text="@string/version" android:background="@color/version_bkgrd" android:textColor="@color/version_color" android:id="@+id/textView3" android:layout_gravity="center_horizontal" android:layout_height="32dp" android:lineSpacingExtra="@dimen/version_spacing"></TextView>
        </LinearLayout>
    </LinearLayout>