当前位置: 首页>>代码示例>>Java>>正文


Java ClipData.newPlainText方法代码示例

本文整理汇总了Java中android.content.ClipData.newPlainText方法的典型用法代码示例。如果您正苦于以下问题:Java ClipData.newPlainText方法的具体用法?Java ClipData.newPlainText怎么用?Java ClipData.newPlainText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.ClipData的用法示例。


在下文中一共展示了ClipData.newPlainText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: copyLink

import android.content.ClipData; //导入方法依赖的package包/类
@Override
public void copyLink() {
    if (checkNull()) {
        view.showCopyTextError();
        return;
    }

    ClipboardManager manager = (ClipboardManager) context.getSystemService(CLIPBOARD_SERVICE);
    ClipData clipData = null;
    switch (type) {
        case TYPE_ZHIHU:
            clipData = ClipData.newPlainText("text", Html.fromHtml(zhihuDailyStory.getShare_url()).toString());
            break;
        case TYPE_GUOKR:
            clipData = ClipData.newPlainText("text", Html.fromHtml(Api.GUOKR_ARTICLE_LINK_V1 + id).toString());
            break;
        case TYPE_DOUBAN:
            clipData = ClipData.newPlainText("text", Html.fromHtml(doubanMomentStory.getOriginal_url()).toString());
    }
    manager.setPrimaryClip(clipData);
    view.showTextCopied();

}
 
开发者ID:makezhao,项目名称:LianXiZhihu,代码行数:24,代码来源:DetailPresenter.java

示例2: setEditText

import android.content.ClipData; //导入方法依赖的package包/类
public void setEditText(@NonNull Context context, @NonNull String text) throws MyException {
    if (null == context) {
        throw new NullPointerException("context");
    }
    if (null == text) {
        throw new NullPointerException("text");
    }
    try {
        //清空内容
        Bundle arguments = new Bundle();
        arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT, AccessibilityNodeInfo
                .MOVEMENT_GRANULARITY_LINE);
        arguments.putBoolean(AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN, true);
        mAccessibilityNodeInfo.performAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY,
                arguments);
        //粘贴内容
        ClipData clipData = ClipData.newPlainText(context.getPackageName(), text);
        ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
        clipboardManager.setPrimaryClip(clipData);
        mAccessibilityNodeInfo.performAction(AccessibilityNodeInfo.ACTION_PASTE);
    } catch (Exception e) {
        throw new MyException(e);
    }
}
 
开发者ID:littleRich,项目名称:AutoInteraction-Library,代码行数:25,代码来源:UiNode.java

示例3: onTouch

import android.content.ClipData; //导入方法依赖的package包/类
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouch(View v, MotionEvent event) {
	if (mSearch.getCompoundDrawables()[2] != null) {
		boolean tappedX = event.getX() > (mSearch.getWidth()
				- mSearch.getPaddingRight() - mIcon.getIntrinsicWidth());
		if (tappedX) {
			if (event.getAction() == MotionEvent.ACTION_UP) {
				if (mSearch.hasFocus()) {
					ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
					ClipData clip = ClipData.newPlainText("label", mSearch.getText()
							.toString());
					clipboard.setPrimaryClip(clip);
					Utils.showToast(
							mActivity,
							mActivity.getResources().getString(
									R.string.message_text_copied));
				} else {
					refreshOrStop();
				}
			}
			return true;
		}
	}
	return false;
}
 
开发者ID:NewCasino,项目名称:browser,代码行数:27,代码来源:BrowserActivity.java

示例4: onClickCopyButton

import android.content.ClipData; //导入方法依赖的package包/类
@OnClick(R.id.signup_pass_phrase_copy_button)
public void onClickCopyButton() {
    ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clip = ClipData.newPlainText("text", address.getText());
    clipboard.setPrimaryClip(clip);

    Utils.showToast("Wallet address copied.");
}
 
开发者ID:SlotNSlot,项目名称:SlotNSlot_Android,代码行数:9,代码来源:SignUpPhraseFragment.java

示例5: copyToClipboard

import android.content.ClipData; //导入方法依赖的package包/类
public static void copyToClipboard(Activity activity, String textToCopy) {
    ClipboardManager clipboard = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clip = ClipData.newPlainText("Remindy text", textToCopy);
    clipboard.setPrimaryClip(clip);

    String toastMsg = String.format(Locale.getDefault(), activity.getResources().getString(R.string.dialog_text_attachment_text_copied_clipboard), textToCopy);
    Toast.makeText(activity, toastMsg, Toast.LENGTH_SHORT).show();
}
 
开发者ID:abicelis,项目名称:Remindy,代码行数:9,代码来源:ClipboardUtil.java

示例6: setText

import android.content.ClipData; //导入方法依赖的package包/类
/** EditText setText */
public static void setText(AccessibilityNodeInfo input, String text) {
    AccessibilityNodeInfoCompat compat = new AccessibilityNodeInfoCompat(input);
    if (Build.VERSION.SDK_INT > 21) {
        Bundle arguments = new Bundle();
        arguments.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, text);
        compat.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, arguments);
    }else{
        ClipboardManager clipboard = (ClipboardManager) Global.getContext().getSystemService(Context.CLIPBOARD_SERVICE);
        ClipData clip = ClipData.newPlainText("text", text);
        clipboard.setPrimaryClip(clip);
        compat.performAction(AccessibilityNodeInfo.ACTION_FOCUS);
        compat.performAction(AccessibilityNodeInfo.ACTION_PASTE);
    }
}
 
开发者ID:A-Miracle,项目名称:QiangHongBao,代码行数:16,代码来源:AccessibilityUtils.java

示例7: copyToClipboard

import android.content.ClipData; //导入方法依赖的package包/类
/**
 *
 * @param text
 */
public void copyToClipboard(CharSequence text) {
    ClipboardManager clipboard = (ClipboardManager) getBaseActivity().getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData addData = ClipData.newPlainText("mnemonic_copied", text);
    clipboard.setPrimaryClip(addData);

    Toast.makeText(getBaseActivity(), "Added to clipboard!", Toast.LENGTH_SHORT).show();
}
 
开发者ID:ehanoc,项目名称:xwallet,代码行数:12,代码来源:BackupFragment.java

示例8: doCopy

import android.content.ClipData; //导入方法依赖的package包/类
public static void doCopy(Context context, String s) {
    //获取剪贴板管理器:
    ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    // 创建普通字符型ClipData
    ClipData mClipData = ClipData.newPlainText("Label", s);
    // 将ClipData内容放到系统剪贴板里。
    cm.setPrimaryClip(mClipData);
    ToastUtil.showToast(context, "已成功复制到剪贴板");
}
 
开发者ID:fengdongfei,项目名称:CXJPadProject,代码行数:10,代码来源:NormalUtil.java

示例9: onLongClick

import android.content.ClipData; //导入方法依赖的package包/类
@Override
public boolean onLongClick(View v) {
    ClipData data = ClipData.newPlainText("simple_text", "text");


    View.DragShadowBuilder sb = new View.DragShadowBuilder(v);

    v.startDrag(data, sb, v, 0);

    v.setVisibility(View.INVISIBLE);




    return (true);
}
 
开发者ID:jvbeltra,项目名称:JavaIsFun,代码行数:17,代码来源:LacoDeRepeticao9.java

示例10: onLinkLongClick2

import android.content.ClipData; //导入方法依赖的package包/类
private void onLinkLongClick2(final String url) {
	DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
           @Override
           public void onClick(DialogInterface dialog, int which) {
               switch (which) {
                   case DialogInterface.BUTTON_POSITIVE:
                       newTab(url, false);
                       break;

                   case DialogInterface.BUTTON_NEGATIVE:
                       getCurrentWebView().loadUrl(url);
                       break;

                   case DialogInterface.BUTTON_NEUTRAL:
                       ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
                       ClipData clip = ClipData.newPlainText("label", url);
                       clipboard.setPrimaryClip(clip);
                       break;
               }
           }
       };

	AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); // dialog
	builder.setTitle(url)
               .setMessage(getResources().getString(R.string.dialog_link))
               .setPositiveButton(getResources().getString(R.string.action_new_tab),
					dialogClickListener)
               .setNegativeButton(getResources().getString(R.string.action_open),
					dialogClickListener)
               .setNeutralButton(getResources().getString(R.string.action_copy),
					dialogClickListener).show();
}
 
开发者ID:NewCasino,项目名称:browser,代码行数:33,代码来源:BrowserActivity.java

示例11: addToClipboard

import android.content.ClipData; //导入方法依赖的package包/类
/**
 * Places a string into the device's clipboard to paste
 *
 * @param context calling context
 * @param label   clip label
 * @param content string to be pasted
 */
public static void addToClipboard(Context context, String label, String content) {
    // Get the clipboard manager
    ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    // Create the new Clip Data with the label and content
    ClipData clip = ClipData.newPlainText(label, content);
    // Put the clip data into the clipboard manager
    clipboard.setPrimaryClip(clip);
}
 
开发者ID:jthomperoo,项目名称:Forge,代码行数:16,代码来源:Util.java

示例12: copy

import android.content.ClipData; //导入方法依赖的package包/类
/**
 * 文本复制
 * @param content
 */
public void copy(String content, Context context)
{
    ClipboardManager cmb = (ClipboardManager)context.getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clip = ClipData.newPlainText("tag", content);
    cmb.setPrimaryClip(clip);
}
 
开发者ID:fiepi,项目名称:moebooru-android,代码行数:11,代码来源:ClipboardUtils.java

示例13: startDrag

import android.content.ClipData; //导入方法依赖的package包/类
public boolean startDrag() {

        if (mDragPotential==null) return false;

        AppLauncher dragitem = (AppLauncher) mDragPotential.getTag();
        String label = dragitem.getLabel();
        ClipData data = ClipData.newPlainText(label, label);
        View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(mDragPotential);

        boolean dragstarted;
        if (Build.VERSION.SDK_INT>=24) {
            dragstarted = mDragPotential.startDragAndDrop(data, shadowBuilder, mDragPotential, 0);
        } else {
            dragstarted = mDragPotential.startDrag(data, shadowBuilder, mDragPotential, 0);
        }

        if (dragstarted) {
            mBeingDragged = dragitem;
            mDragDropSource = (ViewGroup) mDragPotential.getParent();
            Log.d(TAG, "Drag started: " + dragitem.getActivityName() +  ", source = " + mDragDropSource);
            showHiddenCategories();

           // Log.d(TAG, "source = " + mDragDropSource);
            //if (mDragDropSource.getId()!=R.id.icontarget) {
                showRemoveDropzone();
            //}
            return true;
        }


        return false;
    }
 
开发者ID:quaap,项目名称:LaunchTime,代码行数:33,代码来源:MainActivity.java

示例14: onContextItemSelected

import android.content.ClipData; //导入方法依赖的package包/类
@Override
public boolean onContextItemSelected(MenuItem mi)
{
    if (mi.getItemId() == codeText.getId())
    {
    	ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
    	ClipData clip = ClipData.newPlainText("sync_code", codeText.getText());
    	clipboard.setPrimaryClip(clip);
        return true;
    }
    return super.onContextItemSelected(mi);
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:13,代码来源:RMBTSyncRequestCodeFragment.java

示例15: clipBoard

import android.content.ClipData; //导入方法依赖的package包/类
public void clipBoard(View view){
    ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clip = ClipData.newPlainText("email",memail);
    clipboard.setPrimaryClip(clip);
}
 
开发者ID:YoWenqin,项目名称:BuddiesGo,代码行数:6,代码来源:Information.java


注:本文中的android.content.ClipData.newPlainText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。