How to write button onClick method in viewpager?

戏子无情 提交于 2019-11-30 15:20:03

Leave your code all the same but change:

    ((ViewPager) collection).addView(view, 0);

    return view;

to

    ((ViewPager) collection).addView(v, 0);

    return v;

you did the onclick right on a button that was inflated, then you inflated another view iwth resId and rendered it on the screen, that button exists in the memory of your app but no where else, by returning v, that button is drawn and the onclicklistener is invoked on click.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!