本文整理汇总了Java中android.text.ClipboardManager类的典型用法代码示例。如果您正苦于以下问题:Java ClipboardManager类的具体用法?Java ClipboardManager怎么用?Java ClipboardManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClipboardManager类属于android.text包,在下文中一共展示了ClipboardManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.text.ClipboardManager; //导入依赖的package包/类
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.act_pubkeylist);
mListView = (RecyclerView) findViewById(R.id.list);
mListView.setHasFixedSize(true);
mListView.setLayoutManager(new LinearLayoutManager(this));
mListView.addItemDecoration(new ListItemDecoration(this));
mEmptyView = findViewById(R.id.empty);
registerForContextMenu(mListView);
clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
}
示例2: onClick
import android.text.ClipboardManager; //导入依赖的package包/类
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.copyTv:
if (mCommentItem != null) {
ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setText(mCommentItem.getContent());
}
dismiss();
break;
case R.id.deleteTv:
if (mPresenter != null && mCommentItem != null) {
mPresenter.deleteComment(mCirclePosition, FormatUtil.checkValue(mCommentItem.getId()),commentPosition);
}
dismiss();
break;
default:
break;
}
}
示例3: onClick
import android.text.ClipboardManager; //导入依赖的package包/类
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.copyTv:
if (mCommentItem != null) {
ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setText(mCommentItem.getContent());
}
dismiss();
break;
case R.id.deleteTv:
if (bnItemOnClickListener != null && mCommentItem != null) {
bnItemOnClickListener.deleteComment(mCirclePosition, mCommentItem.getId());
}
dismiss();
break;
default:
break;
}
}
示例4: onClick
import android.text.ClipboardManager; //导入依赖的package包/类
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.action_copy:
if (mCommentItem != null) {
ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setText(mCommentItem.getContent());
}
dismiss();
break;
case R.id.action_delete:
if (mBnItemOnClickListener != null && mCommentItem != null) {
mBnItemOnClickListener.deleteComment(mBnPosition, mCommentItem.getId());
}
dismiss();
break;
}
}
示例5: onOptionsItemSelected
import android.text.ClipboardManager; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.item_copy:
ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
cm.setText(url);
SnackBarUtil.showSnackBar(R.string.copy_msg, webView, this);
break;
case R.id.item_browser:
Uri uri = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
break;
}
return super.onOptionsItemSelected(item);
}
示例6: onClick
import android.text.ClipboardManager; //导入依赖的package包/类
public void onClick(View view) {
if (view == this.reverseUnits) {
int inputUnitPosition = this.inputUnit.getSelectedItemPosition();
this.inputUnit.setSelection(this.outputUnit
.getSelectedItemPosition());
this.outputUnit.setSelection(inputUnitPosition);
} else if (view == this.clearInput) {
this.inputAmount.setText("");
} else if (view == this.copyResult) {
CharSequence result = this.outputAmount.getText();
if (result.length() > 0) {
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
clipboard.setText(result);
Toast.makeText(this,
super.getString(R.string.copy_result_message, result),
Toast.LENGTH_SHORT).show();
}
} else {
throw new AssertionError("Unexpected click on view: " + view);
}
this.recalculate();
}
示例7: onClick
import android.text.ClipboardManager; //导入依赖的package包/类
@Override
public void onClick(View v) {
int id = v.getId();
if (id == R.id.btn_copy) {
ClipboardManager clipboarManager = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
clipboarManager.setText(mEtText.getText().toString());
Toast.makeText(this, R.string.added_to_clip_board, Toast.LENGTH_LONG).show();
} else if (id == R.id.btn_search) {
String url = String.format(
"http://m.baidu.com/s?word=%s",
URLEncoder.encode(mEtText.getText().toString()));
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
setResult(RESULT_OK);
finish();
}
}
示例8: draw
import android.text.ClipboardManager; //导入依赖的package包/类
@Override
public void draw() {
if (TextUtils.isEmpty(app.getVideoUrl())) {
return;
}
TextView videoLink = activity.findViewById(R.id.video);
videoLink.setVisibility(View.VISIBLE);
videoLink.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(app.getVideoUrl())));
} catch (ActivityNotFoundException e) {
((ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE)).setText(app.getVideoUrl());
ContextUtil.toast(v.getContext().getApplicationContext(), R.string.about_copied_to_clipboard);
}
}
});
}
示例9: onTextContextMenuItem
import android.text.ClipboardManager; //导入依赖的package包/类
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
@Override
public boolean onTextContextMenuItem(int id) {
if(id == android.R.id.paste){
ClipboardManager clip = (ClipboardManager)getContext().getSystemService(Context.CLIPBOARD_SERVICE);
String text = clip.getText().toString();
if(text.startsWith(ChatActivity.COPY_IMAGE)){
// intent.setDataAndType(Uri.fromFile(new File("/sdcard/mn1.jpg")), "image/*");
text = text.replace(ChatActivity.COPY_IMAGE, "");
Intent intent = new Intent(context,AlertDialog.class);
intent.putExtra("title", "发送以下图片?");
intent.putExtra("forwardImage", text);
intent.putExtra("cancel", true);
((Activity)context).startActivityForResult(intent,ChatActivity.REQUEST_CODE_COPY_AND_PASTE);
// clip.setText("");
}
}
return super.onTextContextMenuItem(id);
}
示例10: onOptionsItemSelected
import android.text.ClipboardManager; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
if(item.getItemId() == CLEAR_CODE)
{
currentLog=new SpannableStringBuilder();
label_log.setText("");
return true;
}
else if(item.getItemId() == COPY_CODE)
{
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
clipboard.setText(currentLog);
Toast.makeText(this,R.string.message_copied,Toast.LENGTH_SHORT).show();
}
return false;
}
示例11: onTextContextMenuItem
import android.text.ClipboardManager; //导入依赖的package包/类
@SuppressLint("NewApi")
@Override
public boolean onTextContextMenuItem(int id) {
if(id == android.R.id.paste){
ClipboardManager clip = (ClipboardManager)getContext().getSystemService(Context.CLIPBOARD_SERVICE);
if (clip == null || clip.getText() == null) {
return false;
}
String text = clip.getText().toString();
if(text.startsWith(ChatActivity.COPY_IMAGE)){
// intent.setDataAndType(Uri.fromFile(new File("/sdcard/mn1.jpg")), "image/*");
text = text.replace(ChatActivity.COPY_IMAGE, "");
Intent intent = new Intent(context,AlertDialog.class);
String str = context.getResources().getString(R.string.Send_the_following_pictures);
intent.putExtra("title", str);
intent.putExtra("forwardImage", text);
intent.putExtra("cancel", true);
((Activity)context).startActivityForResult(intent,ChatActivity.REQUEST_CODE_COPY_AND_PASTE);
// clip.setText("");
}
}
return super.onTextContextMenuItem(id);
}
示例12: onOptionsItemSelected
import android.text.ClipboardManager; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
break;
case R.id.action_refresh: //刷新
mWebView.reload();
break;
case R.id.action_open_in_browser: //在浏览器中打开
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
break;
case R.id.action_copy: //复制网址
ClipboardManager clip = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
clip.setText(url); // 复制
CommonUtil.showSnackbar(mWebView, R.string.copy_to_clipboard, getResources().getColor(R.color.Indigo_colorPrimary));
break;
default:
break;
}
return super.onOptionsItemSelected(item);
}
示例13: testContextMenuCopyToClipboard
import android.text.ClipboardManager; //导入依赖的package包/类
public void testContextMenuCopyToClipboard() throws Exception {
// use HOTP to avoid any timing issues when "current" pin is compared with clip board text.
mAccountDb.update(
"[email protected]", "7777777777777777", "[email protected]", OtpType.HOTP, null);
ListView userList = (ListView) getActivity().findViewById(R.id.user_list);
// find and click next otp button.
View buttonView = getActivity().findViewById(R.id.next_otp);
TestUtilities.clickView(getInstrumentation(), buttonView);
// get the pin being displayed
View listEntry0 = userList.getChildAt(0);
String pin = ((TextView) listEntry0.findViewById(R.id.pin_value)).getText().toString();
TestUtilities.openContextMenuAndInvokeItem(
getInstrumentation(),
getActivity(),
listEntry0,
AuthenticatorActivity.COPY_TO_CLIPBOARD_ID);
// check clip board value.
Context context = getInstrumentation().getTargetContext();
ClipboardManager clipboard =
(ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
assertEquals(pin, clipboard.getText());
}
示例14: RemoteCanvas
import android.text.ClipboardManager; //导入依赖的package包/类
/**
* Constructor used by the inflation apparatus
*
* @param context
*/
public RemoteCanvas(final Context context, AttributeSet attrs) {
super(context, attrs);
clipboard = (ClipboardManager)getContext().getSystemService(Context.CLIPBOARD_SERVICE);
decoder = new Decoder (this);
isRdp = getContext().getPackageName().contains("RDP");
isSpice = getContext().getPackageName().contains("SPICE");
final Display display = ((Activity)context).getWindow().getWindowManager().getDefaultDisplay();
displayWidth = display.getWidth();
displayHeight = display.getHeight();
DisplayMetrics metrics = new DisplayMetrics();
display.getMetrics(metrics);
displayDensity = metrics.density;
if (android.os.Build.MODEL.contains("BlackBerry") ||
android.os.Build.BRAND.contains("BlackBerry") ||
android.os.Build.MANUFACTURER.contains("BlackBerry")) {
bb = true;
}
}
示例15: getView
import android.text.ClipboardManager; //导入依赖的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;
}