本文整理匯總了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();
}
示例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);
}
}
示例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;
}
示例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.");
}
示例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();
}
示例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);
}
}
示例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();
}
示例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, "已成功複製到剪貼板");
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}