2017-04-14 5 views
0

TestGUILibというモジュールがあり、testview.xmlを単純なFrameLayoutで指定しました。Android - 別のモジュールからのレイアウトを含める

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <TextView 
     android:id="@+id/textView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Testing View!" /> 

</FrameLayout> 

私は activity_main私のメインのアプリでこのレイアウトを使用しようとしました。ここに私のコードです:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.example.sam.testapp1.MainActivity"> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Hello World!" 
     app:layout_constraintBottom_toBottomOf="parent" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toTopOf="parent" /> 

    <include layout="@layout/testview" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     /> 

</android.support.constraint.ConstraintLayout> 

すべてがうまくいきます。それはokをコンパイルし、okを実行します。しかし、プレビューは機能しません。これは、レンダリングエラーが発生した(。私は「デザイン」をクリックしたとき、それが空白になりますすなわち)空白の画面を示しています。現在の設定で:

は、レイアウトリソースのマッチング値0x7F04002F(TestViewに解決された名前)を見つけることができませんでした。

また、TestViewに下の行がある(すなわち。レイアウト= "@レイアウト/ TestViewに" が含まれます)。私は以上私のマウスをロールバックするとき、それは言葉で

誤植を言いましTestViewに「

スペルチェッカーの検査は、コード、コメントおよびリテラルにタイプミスやスペルミスを見つけ、ワンクリックでそれらを修正することができます。

ありがとうございました

答えて

2

"ファイル>キャッシュを無効にする/再起動..."に移動し、 "無効にして再起動"をクリックします。それは動作するはずです。

+0

これは機能しました!ありがとうFiroz !!! – Sam

0

あなたはmoduleOnemoduleTwoを持っていて、moduleOneでmoduleTwoリソースを使用する場合のGradle moduleOne中(サンプル)コード次追加したとしましょう

dependencies { 
    compile project(':moduleTwo') 
    } 

あなたが順番にをmoduleTwoにこれはmoduleOneが含まれますには、レイアウトを含むそのリソースを使用します。

関連する問題