简体   繁体   中英

How to make textView highlighted during OnLongClickListener?

I'm sure this is answered somewhere, but I can't find it.

How would I go about making a textview gradually brighten/highlighted during an OnLongClickListener? I have the following code:

jObjTv1.setOnLongClickListener(new View.OnLongClickListener() {

                public boolean onLongClick(View v) {
                    Toast.makeText(root,"Test", Toast.LENGTH_SHORT).show();
                    return true;
                }
            });

Which works just showing me the toast after the long click, but I'd like the textView to be highlighted while being "clicked".

I guess you will have to set a state list drawable as your background for your TextView

<selector xmlns:android="http://schemas.android.com/apk/res/android">

   <item android:state_pressed="true" android:drawable="@drawable/background_transition" />

</selector>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM