本文整理汇总了Java中android.text.ClipboardManager.hasText方法的典型用法代码示例。如果您正苦于以下问题:Java ClipboardManager.hasText方法的具体用法?Java ClipboardManager.hasText怎么用?Java ClipboardManager.hasText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.text.ClipboardManager
的用法示例。
在下文中一共展示了ClipboardManager.hasText方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doPaste
import android.text.ClipboardManager; //导入方法依赖的package包/类
private void doPaste() {
ClipboardManager clip = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE);
if(!clip.hasText()){
Toast tt = Toast.makeText(this, "No text to Paste..", Toast.LENGTH_SHORT);
tt.show();
return;
}
CharSequence paste = clip.getText();
byte[] utf8;
try {
utf8 = paste.toString().getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
Log.e(TermDebug.LOG_TAG, "UTF-8 encoding not found.");
return;
}
getCurrentTermSession().write(paste.toString());
}
示例2: onClick
import android.text.ClipboardManager; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
// Should always be true, because we grey out the clipboard button in onResume() if it's empty
if (clipboard.hasText()) {
launchSearch(clipboard.getText().toString());
}
}
示例3: copySectionContent
import android.text.ClipboardManager; //导入方法依赖的package包/类
private void copySectionContent(int sectionPosition) {
Section s = (Section)mSectionAdapter.getItem(sectionPosition);
String content = getSectionContentInShareMode(s);
ClipboardManager board = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE);
board.setText(content);
if (board.hasText()) {
Toast.makeText(this, R.string.copied, Toast.LENGTH_LONG).show();
}
}
示例4: onClick
import android.text.ClipboardManager; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
// Should always be true, because we grey out the clipboard button in onResume() if it's empty
if (clipboard.hasText()) {
launchSearch(clipboard.getText().toString());
}
}
示例5: fromClipBoard
import android.text.ClipboardManager; //导入方法依赖的package包/类
private String fromClipBoard() {
ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
if (cm.hasText()) {
return cm.getText().toString();
}
doToast(getString(R.string.err_no_clip_text));
return null;
}
示例6: process
import android.text.ClipboardManager; //导入方法依赖的package包/类
public void process(final Context context){
Looper.prepare(); //TODO: review it CAREFULLY
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB){
clipboardNew = (android.content.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
processFailed = !clipboardNew.hasText();
processed = true;
} else {
clipboardOld = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
processFailed = !clipboardOld.hasText();
processed = true;
}
}
示例7: canPaste
import android.text.ClipboardManager; //导入方法依赖的package包/类
private boolean canPaste() {
ClipboardManager clip = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
if (clip.hasText()) {
return true;
}
return false;
}
示例8: onClick
import android.text.ClipboardManager; //导入方法依赖的package包/类
public void onClick(View v) {
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
// Should always be true, because we grey out the clipboard button in onResume() if it's empty
if (clipboard.hasText()) {
launchSearch(clipboard.getText().toString());
}
}
示例9: onResume
import android.text.ClipboardManager; //导入方法依赖的package包/类
@Override
protected void onResume() {
super.onResume();
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
if (clipboard.hasText()) {
clipboardButton.setEnabled(true);
clipboardButton.setText(R.string.button_share_clipboard);
} else {
clipboardButton.setEnabled(false);
clipboardButton.setText(R.string.button_clipboard_empty);
}
}