本文整理汇总了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;
}
}
示例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();
}
}
示例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;
}
}
示例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);
}
示例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();
}
示例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;
}
示例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);
}
示例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";
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}