AndroidThe onClick property is provided for the View in the layout file, and the usage is as follows:
<TextView android: android:layout_width="@dimen/px_171" android:layout_height="fill_parent" android:onClick="iconClickListener" android:clickable="true"/> <TextView android: android:layout_width="@dimen/px_220" android:layout_height="fill_parent" android:layout_gravity="right" android:onClick="iconClickListener" android:clickable="true"/>
/** * Click Event * @param v */ public void iconClickListener(View v) { if(() == ){ }else if(() == ){ } }
Note that the layout file adds clickable=true to TextView (TextView defaults to false), so that it can be used normally.
The above is the full content of the solution to using TextView and setting the onClick attribute invalid that the editor brings to you. I hope everyone supports me~