when i add onclick attribute, application crashes
Closed this issue · 16 comments
hey guy, what's up?
i have problem, when i add android:onclick="..." attr in AutoResizeTextView and after the run it, when i click on the AutoResizeTextView ,application crashes and force close!
but when I change the AutoResizeTextView to TextView, the problem is fixed
i think this is a bug and should be fix it to make better library
Please show it in code. Make a minimal project to demonstrate the issue.
Can't confirm any issue with clicking.
Attached sample project.
MyApplication.zip
your MyApplication not work when click on AutoResizeTextView, ok? you got it?
this is a bug and If you do not know how to fix it, fix it myself
No need for the project
@saeedm1 What is the bug exactly?
Clicking on it will cause the toast that I wrote to appear.
Put a full project and I could check it.
Currently I see there's no bug.
@saeedm1 Here. Attached a video showing that it works just fine.
device-2018-02-10-203015.zip
video.zip
project.zip
the project size is 30MB So I optimized it to 3mb
I can't open it. Please make a minimal working project, showing the issue.
To minimize size of the project, just delete the "build" folders.
Also, have you tried the project I've sent you, showing it works just fine?
And what's the exception exactly?
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mohasebegar, PID: 14383
java.lang.IllegalStateException: Could not find a method primaryMoneyReactionClick(View) in the activity class android.support.v7.widget.TintContextWrapper for onClick handler on view class com.lb.auto_fit_textview.AutoResizeTextView with id 'tvPrimaryMoney'
So there you go. You didn't set it correctly. Nothing related to my library. Would happen to you on a normal TextView too.
Do like I did in the project I've sent you, or just use fineViewById
.
Meaning:
fineViewById(R.id....) . setOnClickListener(...)
ok,I don't have other way for solve this problem.
But I have another problem with style
I'm glad you've solved it.
but i have another problem:
to be able to use AutoResizeTextView, need to specify its boundaries, like this:
<AutoResizeTextView
android:layout_width="0dp"
android:layout_height="0dp"
android:singleLine="true"
android:text="0"
background="#f27070"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
But these bounds are difficult themselves, because when set background color,all marked places are colored, but I just want to change the background color of the text
how can i solve this problem?
That's not related to my library.
It's related to TextView alone.
And for this you can find plenty of solutions on StackOverflow.
Example:
https://stackoverflow.com/questions/15582900/android-textview-text-background-color/15582926