Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

是不是不支持Fragment,我放在Fragment中有问题,如何破 #65

Open
yongchao1210 opened this issue Jul 21, 2017 · 4 comments

Comments

@yongchao1210
Copy link

Process: com.zhy.highlight, PID: 14551
java.lang.IllegalStateException: Could not find method clickKnown(View) in a parent or ancestor Context for android:onClick attribute defined on view class android.widget.ImageView with id 'iv_known'
at android.view.View$DeclaredOnClickListener.resolveMethod(View.java:4758)
at android.view.View$DeclaredOnClickListener.onClick(View.java:4717)
at android.view.View.performClick(View.java:5638)
at android.view.View$PerformClick.run(View.java:22435)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6189)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:887)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:777)

@yongchao1210
Copy link
Author

yongchao1210 commented Jul 21, 2017

info_known.xml 文件中
ImageView
android:id="@+id/iv_known"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/id_iv_tip"
android:src="@drawable/jt_known"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:paddingRight="10dp"
android:onClick="clickKnown"

android:onClick不能用在Fragment的xml中。。。
如何破。。。

@DuShuYuan
Copy link

mHightLight.getHightLightView().findViewById(R.id.iv_known).setOnClickListener(new View.OnClickListener() {
@OverRide
public void onClick(View v) {
clickKnown();
}
});

这样写可以,你运行试试吧还会出其他问题,开始是空指针,你会解决的;弄好以后fragment来回切换还会出问题这个我也解决不了了

@DuShuYuan
Copy link

只能是在ativity里使用了。
在activity里拿到fragment的view就行了
有这个方法:
addHighLight(View view, int decorLayoutId, OnPosCallback onPosCallback, LightShape lightShape)

@chuzhonglingyan
Copy link

注入的点击事件clickKnown写到activity可行。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants