约束问题。找不到符号变量

时间:2018-02-04 12:15:51

标签: android binding

我有一个关于访问基于登机信息和航班信息的布局变量的问题。 在消息面板中抛出无法找到符号变量primaryInfo的错误。我检查了build.gradle,改进了数据绑定,所有xml文件和变量的定义,我也做了一个项目,清理并重建了项目但没有改变。问题仍然存在。我认为问题来自build.gradle文件。我该如何解决?

我在下面分享了他的代码。

MainActivity

public class DetailActivity extends AppCompatActivity implements
        LoaderManager.LoaderCallbacks<Cursor> {

private ActivityDetailBinding mDetailBinding;

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


        mDetailBinding = DataBindingUtil.setContentView(this, R.layout.activity_detail);

        mUri = getIntent().getData();
        if (mUri == null) throw new NullPointerException("URI for DetailActivity cannot be null");

        /* This connects our Activity into the loader lifecycle. */
        getSupportLoaderManager().initLoader(ID_DETAIL_LOADER, null, this);
    }

   mDetailBinding.primaryInfo.weatherIcon.setImageResource(weatherImageId); // ERROR

}

的build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion '27.0.1'

    defaultConfig {
        applicationId "com.example.android.sunshine"
        minSdkVersion 10
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
        }
    }

    dataBinding.enabled = true
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:25.1.0'

    compile 'com.android.support:recyclerview-v7:25.0.1'
    compile 'com.android.support:preference-v7:25.1.0'

    compile 'com.android.support.constraint:constraint-layout:1.0.0-beta3'

    compile 'com.firebase:firebase-jobdispatcher:0.5.0'

    // Instrumentation dependencies use androidTestCompile
    // (as opposed to testCompile for local unit tests run in the JVM)
    androidTestCompile 'junit:junit:4.12'
    androidTestCompile 'com.android.support:support-annotations:25.1.0'
    androidTestCompile 'com.android.support.test:runner:0.5'
    androidTestCompile 'com.android.support.test:rules:0.5'
}

activity.detail.xml

<layout xmlns:android="http://schemas.android.com/apk/res/android">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal">

        <include
            android:id="@+id/primary_info"
            layout="@layout/primary_weather_info"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight=".55" />

        <include
            android:id="@+id/extra_details"
            layout="@layout/extra_weather_details"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight=".45" />

    </LinearLayout>
</layout>

如果你解决了我的问题,我会嘲笑你。

谢谢。

0 个答案:

没有答案