小编sak*_*ony的帖子

安卓数据绑定。如何通过包含布局内的 ID 访问视图

我有一个布局包括一些布局。其中一个有一个progressBar,我想使用数据绑定访问它,但我不能。

<?xml version="1.0" encoding="utf-8"?>
<layout 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"
    >
<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:splitMotionEvents="true"
        tools:context="jp.co.sakony.activities.DiaryNewArticleActivity"
        >

    <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            style="@style/ToolBar"
            />

    <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            >

        <ScrollView
                android:id="@+id/diary_new_article_scrollView"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fillViewport="true"
                >

            <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="@dimen/margin_medium"
                    android:layout_marginRight="@dimen/margin_medium"
                    android:orientation="vertical"
                    android:splitMotionEvents="true"
                    >

                <jp.co.sakony.views.contents.InputFieldDescriptionView
                        android:id="@+id/diary_new_article_input_title_description"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/margin_medium"
                        app:input_field_maxLength="@integer/diary_new_article_title_max_length"
                        app:input_field_required="true"
                        app:input_field_title="@string/diary_new_article_input_title"
                        />

                <android.support.design.widget.TextInputLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="-10dp"
                        app:counterEnabled="true"
                        app:counterMaxLength="@integer/diary_new_article_title_max_length"
                        app:counterTextAppearance="@style/counterText"
                        app:hintTextAppearance="@style/TextAppearence.App.TextInputLayout"
                        >
                    <jp.co.sakony.views.APEditText
                            android:id="@+id/diary_new_article_input_title"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:inputType="text"
                            android:maxLength="@integer/diary_new_article_title_max_length"
                            android:maxLines="1"
                            android:textCursorDrawable="@drawable/shape_edit_cursor_orange"
                            app:textLineColor="@color/orange"
                            />

                </android.support.design.widget.TextInputLayout>

                <jp.co.sakony.views.contents.InputFieldDescriptionView
                        android:id="@+id/diary_new_article_input_body_description"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/margin_medium"
                        app:input_field_maxLength="@integer/diary_new_article_body_max_length"
                        app:input_field_required="true"
                        app:input_field_title="@string/diary_new_article_input_body"
                        />

                <android.support.design.widget.TextInputLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="-10dp" …
Run Code Online (Sandbox Code Playgroud)

data-binding android include

5
推荐指数
2
解决办法
4103
查看次数

标签 统计

android ×1

data-binding ×1

include ×1