Open rohannexialabs opened 9 years ago
Could you try: android:linksClickable="false" and see if it solves your problem?
Thanks for quick response, that's not working. Turns out that JustifiedTextView is consuming click event everywhere.
Could you send the code of your custom TextView ?
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.
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?
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.
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"