正如标题所述,我有一个ScrollView应该监听长按事件,但是没有捕获到任何事件。当我按住ScrollView时什么也不发生 - 没有日志、没有触觉反馈和对话框。
提前感谢!
JAVA:
...
ScrollView text_sv = (ScrollView) findViewById(R.id.text_sv);
text_sv.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
MMMLogs.i("click", "long-click recognized");
AlertDialog.Builder builder = new AlertDialog.Builder(_this);
builder
.setTitle(name)
.setMessage(DHMenuStorage.notification)
.setCancelable(false)
.setNegativeButton("Close", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
return true;
}
});
...
XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="5dp" >
<ScrollView
android:id="@+id/text_sv"
android:layout_width="match_parent"
android:layout_height="75dp"
android:hapticFeedbackEnabled="true"
android:clickable="true"
android:longClickable="true" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/Gray"
android:focusable="false"
android:gravity="center"
android:padding="4dp"
android:text="-- Dining Hall Name --"
android:textColor="@color/Black"
android:textSize="28dp"
android:textStyle="bold" />
<TextView
android:id="@+id/note"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/Gray"
android:focusable="false"
android:gravity="center"
android:padding="4dp"
android:text="-- Special note here --"
android:textColor="@color/Black"
android:textSize="14dp"
android:textStyle="normal" />
</LinearLayout>
</ScrollView>
<TabHost
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="5dp" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp" />
</LinearLayout>
</TabHost>