1

I have an imageView with image loaded in it, and i want to open full screen activity with this image.

<layout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
    <variable
            name="obj"
            type="...ViewObjectImage">
    </variable>
    <variable
            name="handler"
            type="...Handlers">
    </variable>
</data>
<RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        >

    <android.support.v7.widget.CardView
            ...
        <ImageView
               ...
                app:progressbar="@{progressBar}"
                app:imageUrl="@{obj.url}"
                android:onClick="@{(v) -> handler.openFullScreen(v, obj.url)}"
                android:clickable="true"

my Handler class

 public void openFullScreen(View view, String url){
    Context context = view.getContext();
    Intent intent = new Intent(context, FullScreenSingleImageActivity.class);
    intent.putExtra("image_url", url);
    context.startActivity(intent);
}

But when I clicked on ImageView nothing happens. How can i pass second argument with lambda expression in right way?

ZolkiBy
  • 123
  • 1
  • 7
  • It looks like you're doing it already. Try to be more specific about what you're trying to achieve. And why it doesn't work. If you mean to use method references, it's not possible at all. But you're code looks just fine to me. – tynn Apr 16 '17 at 00:44
  • I try open activity with full screen image, but when i clicked on imageview nothing happens – ZolkiBy Apr 16 '17 at 05:38
  • Then it might be related to the body of `openFullScreen()`. You should add it to your question as well. – tynn Apr 16 '17 at 14:42
  • Add code in openFullScreenBody – ZolkiBy Apr 16 '17 at 16:36

2 Answers2

0

Ad the image view to the layout ad set layout parameters to fill the screen

-1

I have this problem, because recyclerview contains different layouts (multiple view type). And all layouts used databinding. I setted handler only for layout in activity. Question was solved when I set handler in adapter to all layouts in recyclerview

@Override
public void onBindViewHolder(CommonViewHolder holder, int position) {
    Object object = getObjForPosition(position);
    holder.bind(object);
    holder.binding.setVariable(BR.handler, mHandlers);
}
ZolkiBy
  • 123
  • 1
  • 7