本文整理汇总了Java中android.view.View.setLongClickable方法的典型用法代码示例。如果您正苦于以下问题:Java View.setLongClickable方法的具体用法?Java View.setLongClickable怎么用?Java View.setLongClickable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.setLongClickable方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: beforeHookedMethod
import android.view.View; //导入方法依赖的package包/类
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
super.beforeHookedMethod(param);
View view = (View) param.thisObject;
// java.lang.RuntimeException:
// Don't call setOnClickListener for an AdapterView.
// You probably want setOnItemClickListener() instead.
if (isAdapterView(view) || view == null) return;
try {
view.setFocusable(true);
view.setClickable(true);
view.setEnabled(true);
view.setLongClickable(true);
view.setOnTouchListener(null);
view.setOnClickListener(null);
view.setOnLongClickListener(null);
} catch (Throwable ignored) {
}
}
示例2: addOnLongClickListener
import android.view.View; //导入方法依赖的package包/类
/**
* add long click view id
*
* @param viewId
* @return if you use adapter bind listener
* @link {(adapter.setOnItemChildLongClickListener(listener))}
* <p>
* or if you can use recyclerView.addOnItemTouch(listerer) wo also support this menthod
*/
@SuppressWarnings("unchecked")
public BaseViewHolder addOnLongClickListener(@IdRes final int viewId) {
itemChildLongClickViewIds.add(viewId);
final View view = getView(viewId);
if (view != null) {
if (!view.isLongClickable()) {
view.setLongClickable(true);
}
view.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
return adapter.getOnItemChildLongClickListener() != null &&
adapter.getOnItemChildLongClickListener().onItemChildLongClick(adapter, v, getClickPosition());
}
});
}
return this;
}
示例3: VerticalItemHolder
import android.view.View; //导入方法依赖的package包/类
public VerticalItemHolder(View itemView, SimpleAdapter adapter) {
super(itemView, mMultiSelector);
itemView.setOnClickListener(this);
itemView.setOnLongClickListener(this);
itemView.setLongClickable(true);
// Initialize adapter for the items
mAdapter = adapter;
// Initialize views
mTitleText = (TextView) itemView.findViewById(R.id.recycle_title);
mDateAndTimeText = (TextView) itemView.findViewById(R.id.recycle_date_time);
mRepeatInfoText = (TextView) itemView.findViewById(R.id.recycle_repeat_info);
mActiveImage = (ImageView) itemView.findViewById(R.id.active_image);
mThumbnailImage = (ImageView) itemView.findViewById(R.id.thumbnail_image);
}
示例4: addOnLongClickListener
import android.view.View; //导入方法依赖的package包/类
/**
* add long click view id
*
* @param viewId
* @return if you use adapter bind listener
* @link {(adapter.setOnItemChildLongClickListener(listener))}
* <p>
* or if you can use recyclerView.addOnItemTouch(listerer) wo also support this menthod
*/
public BaseViewHolder addOnLongClickListener(final int viewId) {
itemChildLongClickViewIds.add(viewId);
final View view = getView(viewId);
if (!view.isLongClickable()) {
view.setLongClickable(true);
}
if (view != null) {
view.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
if (adapter.getmOnItemChildLongClickListener() != null) {
adapter.getmOnItemChildLongClickListener().onItemChildLongClick(adapter, v, getClickPosition());
}
return false;
}
});
}
return this;
}
示例5: getView
import android.view.View; //导入方法依赖的package包/类
@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
if (position < getCount() - (mShowAdd ? 1 : 0)) {
convertView = mInflater.inflate(R.layout.listitem_comment, parent, false);
convertView.setLongClickable(true);
((TextView) convertView.findViewById(R.id.username)).setText(Utils.fromHtml(String.format("<small>%s</small>", users == null ? mObjects.get(position).getUsername() : users.get(mObjects.get(position).getUserId()))));
((TextView) convertView.findViewById(R.id.date)).setText(Utils.fromHtml(String.format("<small>%tF</small>", mObjects.get(position).getDateModification())));
((TextView) convertView.findViewById(R.id.comment)).setText(Utils.fromHtml(mRenderer.render(mParser.parse(mObjects.get(position).getContent()))));
} else {
convertView = mInflater.inflate(android.R.layout.simple_list_item_1, parent, false);
((TextView) convertView.findViewById(android.R.id.text1)).setText(getString(R.string.taskview_fab_new_comment));
((TextView) convertView.findViewById(android.R.id.text1)).setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
}
return convertView;
}
示例6: setTooltipText
import android.view.View; //导入方法依赖的package包/类
/**
* Set the tooltip text for the view.
*
* @param view view to set the tooltip on
* @param tooltipText the tooltip text
*/
public static void setTooltipText(View view, CharSequence tooltipText) {
// The code below is not attempting to update the tooltip text
// for a pending or currently active tooltip, because it may lead
// to updating the wrong tooltipin in some rare cases (e.g. when
// action menu item views are recycled). Instead, the tooltip is
// canceled/hidden. This might still be the wrong tooltip,
// but hiding wrong tooltip is less disruptive UX.
if (sPendingHandler != null && sPendingHandler.mAnchor == view) {
setPendingHandler(null);
}
if (TextUtils.isEmpty(tooltipText)) {
if (sActiveHandler != null && sActiveHandler.mAnchor == view) {
sActiveHandler.hide();
}
view.setOnLongClickListener(null);
view.setLongClickable(false);
view.setOnHoverListener(null);
} else {
new TooltipCompatHandler(view, tooltipText);
}
}
示例7: getView
import android.view.View; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = inflater.inflate(R.layout.account_entry, null);
}
final Account account = accounts.get(position);
((ImageView) convertView.findViewById(R.id.service_logo))
.setImageResource(AccountsUtil.getAccountLogoResource(account.type));
((TextView) convertView.findViewById(R.id.account_name))
.setText(account.name);
((TextView) convertView.findViewById(R.id.account_id)).setText(account.id);
convertView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
callback.callback(account.id);
}
});
convertView.setLongClickable(true);
return convertView;
}
示例8: onCreate
import android.view.View; //导入方法依赖的package包/类
/**
* Set Android UI event handlers and connect to the RightMesh library when the
* activity initializes.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
View buttonSend = findViewById(R.id.button_send);
buttonSend.setOnClickListener(v -> sendMessage(target, colour));
View buttonSendAll = findViewById(R.id.button_sendAll);
buttonSendAll.setOnClickListener(v -> sendAll());
// Display the RightMesh settings activity when the send button is tapped and held.
buttonSend.setLongClickable(true);
buttonSend.setOnLongClickListener(v -> {
try {
mm.showSettingsActivity();
} catch (RightMeshException ignored) { /* Meh. */ }
return true;
});
// Change the background colour when the respective colour buttons are pressed.
findViewById(R.id.button_red).setOnClickListener(v -> setColour("RED"));
findViewById(R.id.button_green).setOnClickListener(v -> setColour("GREEN"));
findViewById(R.id.button_blue).setOnClickListener(v -> setColour("BLUE"));
// Set up the recipient selection spinner.
peersListAdapter = new MeshIDAdapter(this);
component = (RightMeshRecipientComponent) getFragmentManager()
.findFragmentById(R.id.recipient_component);
component.setSpinnerAdapter(peersListAdapter);
component.setOnRecipientChangedListener(this);
// Initialize the RightMesh library with the SSID pattern "Ripple".
mm = AndroidMeshManager.getInstance(MainActivity.this, MainActivity.this, "Ripple");
}
示例9: Folderviewholder
import android.view.View; //导入方法依赖的package包/类
public Folderviewholder(View itemView) {
super(itemView);
thumbnail = (CircleImageView) itemView.findViewById(R.id.artwork);
filename = (TextView) itemView.findViewById(R.id.title);
menu = (ImageButton) itemView.findViewById(R.id.menu_button);
extraParam = (TextView) itemView.findViewById(R.id.artist);
itemView.setOnClickListener(this);
menu.setOnClickListener(this);
itemView.setLongClickable(true);
itemView.setOnLongClickListener(this);
itemView.setOnClickListener(this);
menu.setOnClickListener(this);
}