當前位置: 首頁>>代碼示例>>Java>>正文


Java ClipboardManager.setText方法代碼示例

本文整理匯總了Java中android.text.ClipboardManager.setText方法的典型用法代碼示例。如果您正苦於以下問題:Java ClipboardManager.setText方法的具體用法?Java ClipboardManager.setText怎麽用?Java ClipboardManager.setText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.text.ClipboardManager的用法示例。


在下文中一共展示了ClipboardManager.setText方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: doInBackground

import android.text.ClipboardManager; //導入方法依賴的package包/類
@Override
protected String doInBackground(Integer... params) {
	
	//clear the clipboard after the specified interval
	try{   
		Thread.sleep(params[0]);
		ClipboardManager clipboard = 
			      (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); 
		clipboard.setText("");
		return "success";
		
	}catch(InterruptedException e) {
		e.printStackTrace();
	}
	
	
	return "failure";
	
}
 
開發者ID:dillbyrne,項目名稱:HashPass,代碼行數:20,代碼來源:HashPassActivity.java

示例9: onItemLongClick

import android.text.ClipboardManager; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
    Object o = parent.getItemAtPosition(position);
    if(o == null || !(o instanceof Comment)) return false;
    Comment c = (Comment)o;
    ClipboardManager ma = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN){
        ClipData text = ClipData.newHtmlText(c.userName, c.content, c.content);
        ((android.content.ClipboardManager) ma).setPrimaryClip(text);
    }else{
        ma.setText(c.content);
    }
    Toast.makeText(this, "#"+c.count+"的內容已複製", 0).show();
    return true;
}
 
開發者ID:yrom,項目名稱:AcFun-Area63,代碼行數:17,代碼來源:CommentsActivity.java

示例10: onContextItemSelected

import android.text.ClipboardManager; //導入方法依賴的package包/類
@Override
public boolean onContextItemSelected( MenuItem item )
{
	int pos = ( (AdapterContextMenuInfo) item.getMenuInfo( ) ).position;
	LogItem log = (LogItem) getListView( ).getItemAtPosition( pos );

	if ( log != null && log.getMsg( ) != null )
	{
		ClipboardManager cm = (ClipboardManager) getSystemService( CLIPBOARD_SERVICE );

		if ( cm != null )
		{
			cm.setText( log.getMsg( ) );

			Util.shortToast( this, R.string.copied_hint );
		}
	}

	return true;
}
 
開發者ID:qauck,項目名稱:qsysinfo,代碼行數:21,代碼來源:LogViewer.java

示例11: onOptionsItemSelected

import android.text.ClipboardManager; //導入方法依賴的package包/類
@Override
   public boolean onOptionsItemSelected(MenuItem item) {
	 if (item.getItemId() == android.R.id.home) {
		finish();
		return true;
	} else if (item.getItemId() == R.id.menu_clear_clipboard) {
		ClipboardManager clipBoard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
		clipBoard.setText("");
		return true;
	} else if (item.getItemId() == R.id.menu_settings) {
		Toast toast = Toast.makeText(getApplicationContext(), "You are already on the settings screen", Toast.LENGTH_SHORT);
		toast.show();
		return true;
	} else if (item.getItemId() == R.id.menu_quit) {
		Intent intent = new Intent(getApplicationContext(), MainActivity.class);
		intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		intent.putExtra("EXIT", true);
		startActivity(intent);
		return true;
	} else {
		return super.onOptionsItemSelected(item);
	}
}
 
開發者ID:Qt-dev,項目名稱:CraftMeAPass,代碼行數:24,代碼來源:SettingsActivity.java

示例12: copyText

import android.text.ClipboardManager; //導入方法依賴的package包/類
/**
 * 實現文本複製功能
 *
 * @param content
 */
@SuppressWarnings("deprecation")
public static void copyText(String content, Context context) {
    // 得到剪貼板管理器
    ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    //		ClipData clipData = ClipData.newPlainText(content, content);
    cmb.setText(content);
    //		cmb.setPrimaryClip(clipData);
}
 
開發者ID:Zyj163,項目名稱:yyox,代碼行數:14,代碼來源:Utils.java

示例13: handleCopyMessage

import android.text.ClipboardManager; //導入方法依賴的package包/類
private void handleCopyMessage(final Set<MessageRecord> messageRecords) {
  List<MessageRecord> messageList = new LinkedList<>(messageRecords);
  Collections.sort(messageList, new Comparator<MessageRecord>() {
    @Override
    public int compare(MessageRecord lhs, MessageRecord rhs) {
      if      (lhs.getDateReceived() < rhs.getDateReceived())  return -1;
      else if (lhs.getDateReceived() == rhs.getDateReceived()) return 0;
      else                                                     return 1;
    }
  });

  StringBuilder    bodyBuilder = new StringBuilder();
  ClipboardManager clipboard   = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
  boolean          first       = true;

  for (MessageRecord messageRecord : messageList) {
    String body = messageRecord.getDisplayBody().toString();

    if (body != null) {
      if (!first) bodyBuilder.append('\n');
      bodyBuilder.append(body);
      first = false;
    }
  }

  String result = bodyBuilder.toString();

  if (!TextUtils.isEmpty(result))
      clipboard.setText(result);
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:31,代碼來源:ConversationFragment.java

示例14: copyToClipboard

import android.text.ClipboardManager; //導入方法依賴的package包/類
/**
 * Copies the contents of the network information view to the clipboard.
 */
private void copyToClipboard() {
	try {
		ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
		TextView tv = (TextView) findViewById(R.id.textview);
		cm.setText(tv.getText());
	} catch (Exception ex) {
		Utils.excMsg(this, "Error setting Clipboard", ex);
	}
}
 
開發者ID:KennethEvans,項目名稱:Misc,代碼行數:13,代碼來源:NetworkActivity.java

示例15: onOptionsItemSelected

import android.text.ClipboardManager; //導入方法依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.item_like:
            if (isLiked) {
                item.setIcon(R.drawable.ic_notlike);
                daoManager.deleteByGuid(guid);
                isLiked = false;
                SnackBarUtil.show(((ViewGroup) findViewById(android.R.id.content)).getChildAt(0), "成功從收藏中移除");
            } else {
                item.setIcon(R.drawable.ic_like);
                LikeBean bean = new LikeBean();
                bean.setId(null);
                bean.setGuid(guid);
                bean.setImageUrl(imageUrl);
                bean.setTitle(title);
                bean.setUrl(url);
                bean.setType(type);
                bean.setTime(System.currentTimeMillis());
                daoManager.insert(bean);
                isLiked = true;
                SnackBarUtil.show(((ViewGroup) findViewById(android.R.id.content)).getChildAt(0), "成功添加到收藏");
            }
            break;
        case R.id.item_copy:
            ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
            cm.setText(url);
            SnackBarUtil.show(webView, R.string.copy_msg, 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,項目名稱:Ency,代碼行數:38,代碼來源:WebActivity.java


注:本文中的android.text.ClipboardManager.setText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。