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


Java ClipboardManager类代码示例

本文整理汇总了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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:PubkeyListActivity.java

示例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;
    }
}
 
开发者ID:wp521,项目名称:MyFire,代码行数:21,代码来源:CommentDialog.java

示例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;
	}
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:21,代码来源:CommentDialog.java

示例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;
    }
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:19,代码来源:CommentActionPopup.java

示例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);
}
 
开发者ID:xiarunhao123,项目名称:PureNews,代码行数:17,代码来源:WebUI.java

示例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();
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:23,代码来源:UnitConverterActivity.java

示例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();
    }
}
 
开发者ID:vitaviva,项目名称:QRCodeScanner,代码行数:19,代码来源:TextScanResultActivity.java

示例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);
            }
        }
    });
}
 
开发者ID:yeriomin,项目名称:YalpStore,代码行数:20,代码来源:Video.java

示例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);
    }
 
开发者ID:macyuan,项目名称:TAG,代码行数:21,代码来源:PasteEditText.java

示例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;
}
 
开发者ID:BlueLightJapan,项目名称:BlueLightAPP,代码行数:18,代码来源:ConsoleActivity.java

示例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);
    }
 
开发者ID:tengbinlive,项目名称:info_demo,代码行数:24,代码来源:PasteEditText.java

示例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);
}
 
开发者ID:yuqirong,项目名称:Koku,代码行数:25,代码来源:WebViewActivity.java

示例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());
}
 
开发者ID:ocdtrekkie,项目名称:authenticator,代码行数:23,代码来源:AuthenticatorActivityTest.java

示例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;
    }
}
 
开发者ID:runsoftdev,项目名称:bVnc,代码行数:29,代码来源:RemoteCanvas.java

示例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;
 }
 
开发者ID:sechat,项目名称:android_chat,代码行数:27,代码来源:MessageAdapter.java


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