本文整理匯總了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);
}
}