我在一個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>
添加回答
舉報
0/150
提交
取消