作为Android项目的一部分,我需要创建一个列表视图,可以将图像包含为子视图。
如果我长按图像,长按事件将传递到图像视图,列表视图不会获得长按事件。如何禁用长按子视图并在列表视图上传递长按??
我尝试使用android:longClickable =" false"关于所有儿童观点,但仍然无法正常工作......
请帮助..
private void setChoiceModeListener(final ListView chatListView){ chatListView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL); chatListView.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener(){
@Override
public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
mode.setTitle(String.valueOf(chatListView.getCheckedItemCount()) + " Selected");
mode.invalidate();
}
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
mode.getMenuInflater().inflate(R.menu.menu_actionbar_select, menu);
chatListAdapter.setActionModeEnabled(true);
mActionMode = mode;
return true;
}
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
boolean emailEnabled = EmailUtility.isEmailEnabled(getActivity());
menu.findItem(R.id.select_email).setVisible(emailEnabled);
menu.findItem(R.id.select_copy).setVisible(canEnableCopyMenu());
return true;
}
@Override
public boolean onActionItemClicked(final ActionMode mode, MenuItem item) {
return true;
}
@Override
public void onDestroyActionMode(ActionMode mode) {
chatListView.clearChoices();
chatListView.invalidateViews();
chatListAdapter.setActionModeEnabled(false);
mActionMode = null;
}
});
}
<LinearLayout
android:id="@+id/chat_box"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/date_separator"
android:background="@android:color/transparent"
android:baselineAligned="false"
android:orientation="horizontal"
android:visibility="visible">
<LinearLayout
android:id="@+id/message_box_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/message_boudary_margin"
android:layout_weight="60"
android:background="@drawable/message_item_selector_left"
android:orientation="vertical">
<LinearLayout
android:id="@+id/name_with_time_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:orientation="horizontal">
<CheckedTextView
android:id="@+id/message_posted_time_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="@dimen/margin_medium"
android:autoLink="web"
android:background="@android:color/transparent"
android:gravity="right"
android:singleLine="true"
android:text="@string/chat_bubble_sample_message_posted_time"
android:textColor="@color/message_item_time_color"
android:textSize="@dimen/text_small" />
<CheckedTextView
android:id="@+id/profile_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="@dimen/margin_medium"
android:layout_toLeftOf="@id/message_posted_time_textview"
android:background="@android:color/transparent"
android:ellipsize="end"
android:gravity="left"
android:paddingRight="@dimen/margin_small"
android:singleLine="true"
android:text="@string/lorem_ipsum_short_text"
android:textColor="@color/message_item_profile_name_color"
android:textSize="@dimen/text_small" />
</LinearLayout >
<RelativeLayout
android:id="@+id/imageview_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/name_with_time_layout"
android:layout_centerHorizontal="true"
android:background="@android:color/transparent"
android:paddingBottom="@dimen/margin_small"
android:paddingTop="@dimen/margin_small">
<ImageView
android:id="@+id/message_content_imageview"
android:layout_width="@dimen/chat_attachment_thumbnail_max_size"
android:layout_height="@dimen/chat_attachment_thumbnail_max_size"
android:layout_centerHorizontal="true"
android:contentDescription="@string/app_name"
android:src="@drawable/file_thumb_any" />
<TextView
android:id="@+id/message_content_text_icon"
android:layout_width="@dimen/chat_attachment_thumbnail_max_size"
android:layout_height="@dimen/chat_attachment_thumbnail_max_size"
android:layout_centerHorizontal="true"
android:contentDescription="@string/app_name"
android:gravity="center"
android:text="@string/fa_desktop"
android:textColor="@color/maria_spark"
android:textSize="120sp"
android:visibility="gone" />
<ProgressBar
android:id="@+id/progress_view"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:indeterminate="false"
android:max="100"
android:progressDrawable="@drawable/circular_progress_bar" />
<LinearLayout
android:id="@+id/download_imageview"
android:layout_width="@dimen/chat_attachment_thumbnail_max_size"
android:layout_height="@dimen/chat_attachment_thumbnail_max_size"
android:background="@color/white"
android:gravity="center"
android:alpha="0.5"
android:visibility="gone">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/app_name"
android:src="@drawable/download_icon" />
</LinearLayout>
</RelativeLayout>
<CheckedTextView
android:id="@+id/file_name_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/imageview_layout"
android:layout_centerHorizontal="true"
android:layout_marginLeft="@dimen/margin_extra_large"
android:text="@string/chat_bubble_sample_file_name"
android:textColor="@color/message_item_file_name_color" />
<com.util.views.CheckedLinkTextView
android:id="@+id/message_content_textview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/name_with_time_layout"
android:paddingBottom="5dp"
android:paddingTop="7dp"
android:textColor="@color/message_item_text_color"
android:textSize="@dimen/text_medium" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/message_status_textview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/chat_box"
android:layout_marginLeft="@dimen/margin_medium"
android:layout_marginRight="@dimen/message_boudary_margin"
android:singleLine="true"
android:textColor="@color/maria_spark"
android:textSize="@dimen/text_small"
android:visibility="gone" />
- &GT;