本文整理汇总了Java中android.content.ClipData.Item.getText方法的典型用法代码示例。如果您正苦于以下问题:Java Item.getText方法的具体用法?Java Item.getText怎么用?Java Item.getText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.ClipData.Item
的用法示例。
在下文中一共展示了Item.getText方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPrimaryClipChanged
import android.content.ClipData.Item; //导入方法依赖的package包/类
@Override
public void onPrimaryClipChanged() {
ClipData data = mClipManager.getPrimaryClip();
if (null != data) {
Item item = data.getItemAt(data.getItemCount() - 1);
CharSequence text = item.getText();
if (shouldTranslate(text)) {
TranslateRequest request = new TranslateRequest();
request.mFromLanguage = "auto";
request.mToLanguage = AppSettings.getInstance().mDestLanguage;
mLastText = text.toString();
request.mQuery = mLastText;
mTranslator.startTranslate(request);
lazyResetLastText();
}
}
}
示例2: processDrop
import android.content.ClipData.Item; //导入方法依赖的package包/类
boolean processDrop(DragEvent event, ImageView imageView) {
// Attempt to parse clip data with expected format: category||entry_id.
// Ignore event if data does not conform to this format.
ClipData data = event.getClipData();
if (data != null) {
if (data.getItemCount() > 0) {
Item item = data.getItemAt(0);
String textData = (String) item.getText();
if (textData != null) {
StringTokenizer tokenizer = new StringTokenizer(textData, "||");
if (tokenizer.countTokens() != 2) {
return false;
}
int category = -1;
int entryId = -1;
try {
category = Integer.parseInt(tokenizer.nextToken());
entryId = Integer.parseInt(tokenizer.nextToken());
} catch (NumberFormatException exception) {
return false;
}
updateContentAndRecycleBitmap(category, entryId);
// Update list fragment with selected entry.
TitlesFragment titlesFrag = (TitlesFragment)
getFragmentManager().findFragmentById(R.id.titles_frag);
titlesFrag.selectPosition(entryId);
return true;
}
}
}
return false;
}
示例3: extractURL
import android.content.ClipData.Item; //导入方法依赖的package包/类
protected String extractURL() {
String url = null;
ClipData clipboard = getIntent().getClipData();
if ( clipboard.getItemCount() > 0 ) {
Item item = clipboard.getItemAt( 0 );
if ( item != null && item.getText() != null ) {
url = item.getText().toString();
}
}
return url;
}
示例4: processDrop
import android.content.ClipData.Item; //导入方法依赖的package包/类
boolean processDrop(DragEvent event, ImageView imageView) {
// Attempt to parse clip data with expected format: category||entry_id.
// Ignore event if data does not conform to this format.
ClipData data = event.getClipData();
if (data != null) {
if (data.getItemCount() > 0) {
Item item = data.getItemAt(0);
String textData = (String) item.getText();
if (textData != null) {
StringTokenizer tokenizer = new StringTokenizer(textData, "||");
if (tokenizer.countTokens() != 2) {
return false;
}
int category = -1;
int entryId = -1;
try {
category = Integer.parseInt(tokenizer.nextToken());
entryId = Integer.parseInt(tokenizer.nextToken());
} catch (NumberFormatException exception) {
return false;
}
updateContentAndRecycleBitmap(category, entryId);
// Update list fragment with selected entry.
TitlesFragment titlesFrag = (TitlesFragment)
getFragmentManager().findFragmentById(R.id.frag_title);
titlesFrag.selectPosition(entryId);
return true;
}
}
}
return false;
}