當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。