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?
将图片视图投放到布局广告集布局参数以填充屏幕
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);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.