I was using direct childs in my layout xml, everthing was perfect while binding layouts with activity. I could use binding.bannerPager.setOffscreenPageLimit(3);
but when i replaced direct childrens with <include/>
tag, then i can not use binding.bannerPager
any more, i searched this bannerPager
in ViewDataBinding of my activity. But my bad i could not find that.
Here is my activity class.
public class ActivityRestaurantDetail extends BaseActivity {
private ActivityRestaurantDetailBinding binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_restaurant_detail);
binding.setActivity(this);
binding.bannerPager.setOffscreenPageLimit(3);
in activity_restaurant_detail.xml i have include an layout which i need in many layouts.
<include layout="@layout/layout_banner_image"/>
Here is layout_banner_image.xml
<RelativeLayout
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="@dimen/_150sdp">
<android.support.v4.view.ViewPager
android:id="@+id/banner_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/grey_rect"/>
<com.amelio.utils.CircleView
android:id="@+id/circle_view"
android:layout_width="match_parent"
android:layout_height="@dimen/_5sdp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="@dimen/_8sdp"
app:accent_color="@android:color/white"
app:base_color="@color/light_grey"/>
</RelativeLayout>
My Question is :
As solution i used findViewById then replaced binding.bannerPager
with bannerPager.someMethod(), But i want to access components like before.
What should i do so i can access components like binding.bannerPager
, and i dont have to use findViewById
?