모두 여러분! :)안드로이드 스튜디오의 Tabitem 바인딩
탭이있는 활동 (또는 단편) 탭에 맞춤 레이아웃이 필요합니다. tab_item_layout.xml Databinding에 필요한
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<LinearLayout
android:id="@+id/tab_item_root_linear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/tab_item_name_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="Wink from"/>
<TextView
android:id="@+id/tab_item_number_text_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
tools:text="1"/>
</LinearLayout>
</layout>
레이아웃 태그 :
제일 -
은> 나는 TabItem의이 레이아웃을 정의했다.2 -,는> (조각에하지만 난이 연결되지 않은)을 tablayout 정의 : fragment_surf_base.xml를
<android.support.design.widget.TabLayout
android:id="@+id/surf_tab_layout"
android:layout_width="368dp"
android:layout_height="0dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<android.support.design.widget.TabItem
android:id="@+id/tabItem1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout="@layout/tab_item_layout" />
<android.support.design.widget.TabItem
android:id="@+id/tabItem2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout="@layout/tab_item_layout" />
<android.support.design.widget.TabItem
android:id="@+id/tabItem3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout="@layout/tab_item_layout" />
</android.support.design.widget.TabLayout>
(이 tablayout와 조각입니다) 그리고 난 (탭 항목에 대한 필요
Initilazie 내 바인딩 클래스 인스턴스 :
binding = DataBindingUtil.inflate(inflater,R.layout.fragment_surf_base, container, false);
,536 이러한 코드와 자바 파일에) 바인딩
자,이 바인딩 인스턴스를 사용하여 (return null !! 하지만 왜?) :
binding.tabItem1; 이것은 null이지만 왜 그런지 모르겠습니다.
이와 나는 binding.tabItem1.bindingClassInstanceReturnedItem < <하여 tab_item_layout 바인딩 클래스 인스턴스와 TabItem의 레이아웃 항목 (tab_item_name_text_view 및 tab_item_number_text_view)가 필요합니다 -하지만 난이 없습니다 :
어떤 생각 \ 이 문제는? : \ 안녕! :)
(죄송합니다 내 영어 나쁜)
당신은 다음과 같이 바인딩을 얻기 위해 fragment_surf_base.xml에 데이터 바인딩을 수행 할 필요가
나는 이것을 알고있다. 하지만 나는 tabitem 레이아웃 아이템 바인딩이 필요하다. 예 : binding.tabitem1.nameTextView.setText ("asdad"). 편집 : 그리고 binding.tabItem1 null입니다 하지만이 null이 아닌 tablayout.getTabAt (0) 사용하지만이 Tablayout.tab 및 tabitem 또는 기타 캐스팅 모르겠다. –