제목에서 말했듯이, 나는 scrollclock을 듣고 있어야하지만, 잡는 중이다. scrollview- 로그가없고 햅틱 피드백이 없으면 & 대화 상자가 표시되지 않습니다.안드로이드 Scrollview 잡기 longclick
미리 감사드립니다.
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>
코드에 OnTouchListener 또는 OnClickListener가 있습니까? OnLongClickListener의 프로세스를 중단시킬 수 있습니다. 메소드의 반환 값에주의하십시오. – Davidsun
tabHost가 자체적으로 생성하지 않는 한 -이 클래스의 다른 수신기는 내 OnTabChangedListener()뿐입니다. – bhekman
추가 작업을 수행 한 결과 동일한 리스너가 scrollview에 포함 된 textview에 대해 잘 작동한다는 것을 알았습니다. 두 명의 리스너를 만들고 싶지는 않습니다. 아무도 이것을 설명 할 수 있습니까 ?? – bhekman