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

Consuming click event #3

Open
rohannexialabs opened this issue Sep 22, 2015 · 6 comments
Open

Consuming click event #3

rohannexialabs opened this issue Sep 22, 2015 · 6 comments

Comments

@rohannexialabs
Copy link

I am using using your JustifiedTextView everywhere in my app but it is consuming click event itself. If I use normal TextView then it is working fine.

I have tried setting following attributes in the xml to JustifiedTextView but it is still consuming click event. What else can I do ?
android:clickable="false" android:enabled="false" android:focusable="false" android:focusableInTouchMode="false"

@programingjd
Copy link
Owner

Could you try:
android:linksClickable="false"
and see if it solves your problem?

@rohannexialabs rohannexialabs changed the title Consuming click event when using with Sliding tabs Consuming click event Sep 22, 2015
@rohannexialabs
Copy link
Author

Thanks for quick response, that's not working. Turns out that JustifiedTextView is consuming click event everywhere.

@programingjd
Copy link
Owner

Could you send the code of your custom TextView ?

@rohannexialabs
Copy link
Author

Code for CustomTextView -

public class CustomTextView extends TextView {

public CustomTextView(Context context) {
    super(context);
}

public CustomTextView(Context context, AttributeSet attrs) {
    super(context, attrs);
    CustomFontHelper.setCustomFont(this, context, attrs);
}

public CustomTextView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    CustomFontHelper.setCustomFont(this, context, attrs);
}

}

I was testing in a different scenario in which the JustifiedTextView was inside a ViewPager. On click of the TextView, I had to perform an event. Using a custom TextView extending TextView is working fine but if I extend JustifiedTextView, clicks are not going through.

Even if I use JustifiedTextView in xml as child of ViewPager, it is consuming click event.

@programingjd
Copy link
Owner

I tried to adjust the code of the example to test it (app/src/java/com/uncopt/android/example/justify/MyJustifiedTextView). This is also a class extending JustifiedTextView and it is inside a ViewPager.
If I add this to the constructor:
setOnClickListener(new View.OnClickListener() {
@OverRide public void onClick(final @NotNull View v) {
Toast.makeText(context, "Click", Toast.LENGTH_SHORT).show();
}
});
It is working properly. I get the "Click" message (unless I click on a link, which is the expected behavior).

If you comment the lines with
CustomFontHelper.setCustomFont(this, context, attrs);

but still use your CustomTextView, does it work?

@rohannexialabs
Copy link
Author

I tried your solution but it didn't work. Forget about JustifiedTextView in a ViewPager, when extend JustifiedTextView, all the TextView starts consuming event (even after removing setFont()).

Eg - consider a linear layout with padded TextView. I have a onClickListener on LinearLayout which works fine with TextView .i.e either I click on the empty space or on the TextView, I get click event. However, if I extend JustifiedTextView, clicking on the text stops working. If I click on the empty space of linear layout, I get click event. However, if I click on text, no event is fired.

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

2 participants