下面列出了android.widget.TextView#setLongClickable ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public MessageHolder(final View itemView) {
super(itemView);
gravatar = (ImageView) itemView.findViewById(R.id.gravatar);
senderName = (TextView) itemView.findViewById(R.id.senderName);
timestamp = (TextView) itemView.findViewById(R.id.timestamp);
leftTimestamp = (TextView) itemView.findViewById(R.id.left_timestamp);
edited = (TextView) itemView.findViewById(R.id.message_edit_tag);
leftEdited = (TextView) itemView.findViewById(R.id.left_message_edit_tag);
contentView = (TextView) itemView.findViewById(R.id.contentView);
contentView.setMovementMethod(LinkMovementMethod.getInstance());
leftBar = itemView.findViewById(R.id.leftBar);
messageTile = (RelativeLayout) itemView.findViewById(R.id.messageTile);
contentImage = (ImageView) itemView.findViewById(R.id.load_image);
starImage = (ImageView) itemView.findViewById(R.id.star_image);
leftStarImage = (ImageView) itemView.findViewById(R.id.left_star_image);
contentImageContainer = itemView.findViewById(R.id.load_image_container);
reactionsTable = (TableLayout) itemView.findViewById(R.id.reactions_table);
contentView.setOnClickListener(this);
contentView.setLongClickable(true);
itemView.setOnCreateContextMenuListener(this);
// Add click listener to sender view
View senderView = itemView.findViewById(R.id.senderTile);
if (senderView != null) senderView.setOnClickListener(this);
}
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
TextView text = holder.itemView.findViewById(android.R.id.summary);
text.setMovementMethod(new LinkMovementMethod());
text.setClickable(true);
text.setLongClickable(false);
holder.itemView.setClickable(false);
}
/**
* Sets the given `TextView` to be read-only or read-and-write
*
* @param view a `TextView` or one of its subclasses
* @param readOnly whether the view should be read-only or not
*/
public static void setReadOnly(final TextView view, final boolean readOnly) {
view.setFocusable(!readOnly);
view.setFocusableInTouchMode(!readOnly);
view.setClickable(!readOnly);
view.setLongClickable(!readOnly);
view.setCursorVisible(!readOnly);
}
/**
* Work around some 'features' of TextView and URLSpans. i.e. vanilla URLSpans do not react to
* touch so we replace them with our own {@link io.plaidapp.ui.span
* .TouchableUrlSpan}
* & {@link io.plaidapp.util.LinkTouchMovementMethod} to fix this.
* <p>
* Setting a custom MovementMethod on a TextView also alters touch handling (see
* TextView#fixFocusableAndClickableSettings) so we need to correct this.
*
* @param textView
* @param input
*/
public static void setTextWithNiceLinks(TextView textView, CharSequence input) {
textView.setText(input);
textView.setMovementMethod(LinkTouchMovementMethod.getInstance());
textView.setFocusable(false);
textView.setClickable(false);
textView.setLongClickable(false);
}
/**
* Work around some 'features' of TextView and URLSpans. i.e. vanilla URLSpans do not react to
* touch so we replace them with our own {@link TouchableUrlSpan}
* & {@link LinkTouchMovementMethod} to fix this.
* <p/>
* Setting a custom MovementMethod on a TextView also alters touch handling (see
* TextView#fixFocusableAndClickableSettings) so we need to correct this.
*/
public static void setTextWithNiceLinks(TextView textView, CharSequence input) {
textView.setText(input);
textView.setMovementMethod(LinkTouchMovementMethod.getInstance());
textView.setFocusable(false);
textView.setClickable(false);
textView.setLongClickable(false);
}