本文整理汇总了Java中android.view.View.OnLongClickListener类的典型用法代码示例。如果您正苦于以下问题:Java OnLongClickListener类的具体用法?Java OnLongClickListener怎么用?Java OnLongClickListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OnLongClickListener类属于android.view.View包,在下文中一共展示了OnLongClickListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bindEvent
import android.view.View.OnLongClickListener; //导入依赖的package包/类
/**
* Bind events(touch, click, longclick etc).
*
* @param listener
* @param view
*/
public void bindEvent(final View view, final OnLongClickListener listener)
{
if (view == null)
{
throw new NullPointerException("Can not bind event to null view.");
}
view.setOnLongClickListener(new OnLongClickListener()
{
@Override
public boolean onLongClick(View v)
{
if (listener != null)
{
return listener.onLongClick(v);
}
return false;
}
});
}
示例2: ServerViewHolder
import android.view.View.OnLongClickListener; //导入依赖的package包/类
public ServerViewHolder(View view) {
super(view);
view.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(final View v) {
PopupMenu menu = ServerInfoUtil.createContextMenu(context, v, new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
return ServerInfoUtil.onMenuItemClick(context, item, serverInfo, after);
}
});
menu.show();
return true;
}
});
icon = (ImageView) view.findViewById(R.id.icon);
serverName = (TextView) view.findViewById(R.id.server_name);
serverAddress = (TextView) view.findViewById(R.id.server_address);
serverLocator = (TextView) view.findViewById(R.id.server_locator_id);
serverLastConnected = (TextView) view.findViewById(R.id.server_last_connect);
}
示例3: setupChildView
import android.view.View.OnLongClickListener; //导入依赖的package包/类
@Override
public View setupChildView(int childPosition, ListObject object, View convertView, ViewGroup parent)
{
final TextView infoText=(TextView)convertView.findViewById(R.id.card_info_title),
valueText =(TextView)convertView.findViewById(R.id.card_info_value);
InfoObject infoObject=(InfoObject)object;
infoText.setText(infoObject.info);
valueText.setText(infoObject.value);
infoTextViews.add(valueText);
convertView.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
ClipboardManager clipboard=(ClipboardManager)context.getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setText(valueText.getText().toString());
Toast.makeText(context,"Copied to clipboard",Toast.LENGTH_SHORT).show();
return false;
}
});
return convertView;
}
示例4: bindText
import android.view.View.OnLongClickListener; //导入依赖的package包/类
private void bindText(Context context, int position, TextHolder holder, View convertView, final GotyeTextMessageProxy msg){
if(msg.get().getText().length() < 5){
holder.contentView.setGravity(Gravity.CENTER);
}else {
holder.contentView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
}
CharSequence sqe = msg.getTextCharSeq();
if(sqe == null){
msg.setTextCharSeq(SmileyUtil.replace(context, context.getResources(), msg.get().getText()));
}
holder.contentView.setText(msg.getTextCharSeq());
holder.contentView.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
activity.showMessagePannel(v, msg);
return true;
}
});
}
示例5: getView
import android.view.View.OnLongClickListener; //导入依赖的package包/类
public View getView(int position, View convertView, ViewGroup parent) {
View vi = convertView;
final Discussion entry = data.get(position);
if (entry.getMe()) vi = inflater.inflate(R.layout.message_list_out, null);
else vi = inflater.inflate(R.layout.message_list_in, null);
LinearLayout list = (LinearLayout)vi.findViewById(R.id.messageList);
TextView time = (TextView)vi.findViewById(R.id.time);
TextView message = (TextView)vi.findViewById(R.id.message);
list.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View arg0) {
ClipboardManager cm = (ClipboardManager) activity
.getSystemService(Context.CLIPBOARD_SERVICE);
cm.setText(entry.getMessage());
th.sendNotification(activity, "Copied to clipboard");
return true;
}
});
message.setText(entry.getMessage());
Timestamp timestamp = entry.getTimestamp();
time.setText(timestamp.getHours()+":"+timestamp.getMinutes());
return vi;
}
示例6: init
import android.view.View.OnLongClickListener; //导入依赖的package包/类
void init() {
setState(STATE_IDLE);
mVUMeterViewL.setOrientation(false);
mSoundRecorder.setVUMMax(VUM_MAX_NUM);
mCusImage.setOnClickListener(mListener);
mTvShow.setOnClickListener(mListener);
mTvCancel.setOnClickListener(mListener);
mCusImage.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Logger.info("", "开始录音");
clickMain();
return true;
}
});
}
示例7: handleInitPackageResources
import android.view.View.OnLongClickListener; //导入依赖的package包/类
public void handleInitPackageResources(InitPackageResourcesParam resparam) throws Throwable {
resparam.res.hookLayout("android", "layout", "text_edit_action_popup_text", new XC_LayoutInflated() {
@Override
public void handleLayoutInflated(LayoutInflatedParam liparam) throws Throwable {
final TextView text = (TextView) liparam.view;
text.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
if(Resources.getSystem().getString(android.R.string.paste).equals(text.getText().toString())){
if(pref.getBoolean("pastefunction", false))
Etextview.onTextContextMenuItem(android.R.id.paste);
else {
Open(text.getContext(),Etextview);
WaitforClip(text.getContext(), Etextview);
}
return true;
}else {
Toast.makeText(text.getContext(), "Long Clicked "+text.getText().toString(), Toast.LENGTH_SHORT).show();
return false;
}
}
});
}
});
}
示例8: setAbilityWidgetListener
import android.view.View.OnLongClickListener; //导入依赖的package包/类
private void setAbilityWidgetListener(final AbilityScoreView widget) {
widget.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
AbilityScorePickerFragment fragment = AbilityScorePickerFragment.newInstance(
widget.getAbility(),
widget.getScore());
FragmentManager fm = getActivity().getSupportFragmentManager();
fragment.setTargetFragment(CharacterSheetFragment.this, REQUEST_SCORE);
fragment.show(fm, SCORE_DIALOG_TAG);
return true;
}
});
}
示例9: showTutorial
import android.view.View.OnLongClickListener; //导入依赖的package包/类
void showTutorial() {
if ((adapter.getCount() > 0
&& PreferenceManager.getDefaultSharedPreferences(context)
.getBoolean("showVaultLongClickTutorial", true))) {
final View mView =
context.getLayoutInflater().inflate(R.layout.vault_item_tutorial, mLinearView, false);
TextView mInstructions = (TextView) mView.findViewById(R.id.Tutorial__instruction);
if (mInstructions != null)
mInstructions.setText(R.string.Tutorial__long_click_to_rename);
mLinearView.addView(mView, 0);
mView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
mLinearView.removeView(mView);
SharedPreferences.Editor editor
= PreferenceManager.getDefaultSharedPreferences(context).edit();
editor.putBoolean("showVaultLongClickTutorial", false);
editor.apply();
return true;
}
});
}
}
示例10: setEditTextLongClick
import android.view.View.OnLongClickListener; //导入依赖的package包/类
/**
* Sets long click listener for one EditText
*
* @param editText EditText for sets long click listener
*/
private void setEditTextLongClick(final EditText editText) {
Log.message("Enter");
editText.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View arg0) {
Log.message("Enter");
switch (arg0.getId()) {
case R.id.sunset_editText_date:
initDate();
updateDate();
break;
case R.id.sunset_editText_location:
handleCurrentLocation();
break;
}
return true;
}
});
}
示例11: getTab
import android.view.View.OnLongClickListener; //导入依赖的package包/类
public TextView getTab(final int position, SwipeyTabs root) {
final TextView view = (TextView) LayoutInflater.from(mContext).inflate(R.layout.swipey_tab_indicator, root, false);
view.setText(TITLES[position]);
view.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
mViewPager.setCurrentItem(position);
}
});
view.setOnLongClickListener(new OnLongClickListener() {
public boolean onLongClick(View v) {
Intent i = new Intent(getApplicationContext(), InfoCanteens.class);
i.putExtra("canteens", view.getText());
startActivity(i);
return true;
}
});
return view;
}
示例12: onCreate
import android.view.View.OnLongClickListener; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.i(TAG, "onCreate");
setContentView(io.selendroid.testapp.R.layout.homescreen);
Button button = (Button) findViewById(io.selendroid.testapp.R.id.buttonTest);
button.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
showDialog(DIALOG_LONG_PRESS);
return true;
}
});
initExceptionTestButton();
initExceptionTestField();
}
示例13: buildBottomBarButton
import android.view.View.OnLongClickListener; //导入依赖的package包/类
/**
* Builds an {@link ImageButton} from the data in this params. Generated buttons should be
* placed on the bottom bar. The button's tag will be its id.
* @param parent The parent that the inflated {@link ImageButton}.
* @param listener {@link OnClickListener} that should be used with the button.
* @return Parsed list of {@link CustomButtonParams}, which is empty if the input is invalid.
*/
ImageButton buildBottomBarButton(Context context, ViewGroup parent, OnClickListener listener) {
if (mIsOnToolbar) return null;
ImageButton button = (ImageButton) LayoutInflater.from(context)
.inflate(R.layout.custom_tabs_bottombar_item, parent, false);
button.setId(mId);
button.setImageBitmap(mIcon);
button.setContentDescription(mDescription);
if (mPendingIntent == null) {
button.setEnabled(false);
} else {
button.setOnClickListener(listener);
}
button.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
final int screenWidth = view.getResources().getDisplayMetrics().widthPixels;
final int screenHeight = view.getResources().getDisplayMetrics().heightPixels;
final int[] screenPos = new int[2];
view.getLocationOnScreen(screenPos);
final int width = view.getWidth();
Toast toast = Toast.makeText(
view.getContext(), view.getContentDescription(), Toast.LENGTH_SHORT);
toast.setGravity(Gravity.BOTTOM | Gravity.END,
screenWidth - screenPos[0] - width / 2,
screenHeight - screenPos[1]);
toast.show();
return true;
}
});
return button;
}
示例14: initTimeAndBody
import android.view.View.OnLongClickListener; //导入依赖的package包/类
protected void initTimeAndBody(TextView timeText, TextView bodyText, final Post post) {
timeText.setText(DateHelper.timezoneFormat(post.created_at, "MM-dd HH:mm"));
bodyText.setOnLongClickListener(new OnLongClickListener() {
public boolean onLongClick(View v) {
TimeLineUtility.copyText(BaseTimelineAdapter.this.activity, post.body);
Helper.showToast(BaseTimelineAdapter.this.activity, (CharSequence) "内容已复制到剪切板");
return true;
}
});
TimeLineUtility.addLinksWithShowMore(bodyText, post);
}
示例15: onDualModeSet
import android.view.View.OnLongClickListener; //导入依赖的package包/类
@Override
public void onDualModeSet(View tileView, boolean enabled) {
if (enabled) {
View bgView = (View) XposedHelpers.getObjectField(tileView, "mTopBackgroundView");
bgView.setOnLongClickListener((OnLongClickListener)
XposedHelpers.getObjectField(tileView, "mLongClick"));
}
}