Two textviews belong to view.
When I use setOnTouchListener on the view, the touch only succeeds once out of multiple attempts.
When I use setOnTouchListener for textAprName which is part of the textview, the touch works fine.
I want to smoothly touch both textviews.
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View? {
var convertView:View? = convertView
val context = parent.context
val aprInfo = aprList[position]
var textAprName: TextView? = null
var textApr: TextView? = null
var holder: AprItemHolder? = null
if (convertView == null) {
val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
convertView = inflater.inflate(R.layout.apr_item_view, parent, false)
textAprName = convertView?.findViewById(R.id.text_apr_name) as TextView
textApr = convertView?.findViewById(R.id.text_apr) as TextView
holder = AprItemHolder()
holder.textAprName = textAprName
holder.textApr = textApr
convertView.tag = holder
} else {
holder = convertView.tag as AprItemHolder
textAprName = holder.textAprName
textApr = holder.textApr
}
textAprName?.text = aprInfo.name
textApr?.text = aprInfo.description
convertView?.setOnTouchListener @SuppressLint("ClickableViewAccessibility"){ v, event ->
var action: Int = MotionEventCompat.getActionMasked(event)
when (action) {
MotionEvent.ACTION_UP -> {
StandElin.instance!!.SendApr(aprInfo.name)
closeDialog()
}
}
true
}
return convertView
}
about layout.apr_item_view
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="289dp"
android:layout_height="95dp"
android:descendantFocusability="blocksDescendants"
android:background="@drawable/btn_apr1">
<com.dkms.elin7.view.FontTextView
android:id="@+id/text_apr_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:gravity="center"
android:text="APR 1"
android:textColor="@color/white"
android:textSize="30sp"
app:font="@string/font_gotham_book" />
<com.dkms.elin7.view.FontTextView
android:id="@+id/text_apr"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="49dp"
android:gravity="center"
android:text="Stand,110,0"
android:textColor="@color/apr_text"
android:textSize="23sp"
app:font="@string/font_gotham_book" />
I converted the java project to kotlin.
It worked in the existing java, but not in kotlin.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…