第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

OnTouchListener 不能使用 relative layout

OnTouchListener 不能使用 relative layout

ABOUTYOU 2019-04-03 22:19:03
我在一個RelativeLayout中動態(tài)的添加了很多TextViews。我現(xiàn)在面臨的問題是:不論什么時候當(dāng)我單獨申請一個 onTouch 監(jiān)聽器到TextViews,當(dāng)我添加touch事件到relative layout時它能檢測到touch 事件,但是沒有回應(yīng)。檢測touch事件代碼:TextView tv = new TextView(this); tv.setText(values[i]); Drawable d = getResources().getDrawable(R.drawable.level_small_corners); tv.setClickable(true); tv.setId(i+1); tv.setTextSize(18); tv.setOnTouchListener(cellTouch);但是我在 myRelativeLayout 添加所有的 TextViewsmyRelativeLayout.setOnTouchListener(cellTouch);現(xiàn)在 onTouchListener 也不能調(diào)用,為什么?<?xml version="1.0" encoding="utf-8"?>     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"         android:layout_width="fill_parent"         android:layout_height="fill_parent"         android:background="@android:color/black"     >     .     .     .     <ScrollView               android:layout_width="fill_parent"               android:layout_height="wrap_content"              android:layout_below="@+id/levelFirstLayout"              android:layout_marginBottom="70dp"              >          <RelativeLayout                android:id="@+id/wordsRelativeLayout"              android:layout_width="fill_parent"               android:clickable="true"                 android:layout_height="wrap_content" android:clickable="true" android:focusable="true" android:focusableInTouchMode="true"             >         </RelativeLayout>         </ScrollView>      .     .     .         </RelativeLayout>
查看完整描述

4 回答

?
慕容3067478

TA貢獻1773條經(jīng)驗 獲得超3個贊

問題出在 tv.setClickable(true);,刪除這條語句。


查看完整回答
反對 回復(fù) 2019-04-28
?
紅糖糍粑

TA貢獻1815條經(jīng)驗 獲得超6個贊

在 myRelativeLayout.xml 添加:

android:clickable="true"
android:focusable="true"
android:focusableInTouchMode="true"


查看完整回答
反對 回復(fù) 2019-04-28
  • 4 回答
  • 0 關(guān)注
  • 734 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號