本文整理汇总了Java中android.content.ClipData.Item类的典型用法代码示例。如果您正苦于以下问题:Java Item类的具体用法?Java Item怎么用?Java Item使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Item类属于android.content.ClipData包,在下文中一共展示了Item类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: a
import android.content.ClipData.Item; //导入依赖的package包/类
@TargetApi(16)
public static void a(Intent paramIntent, String paramString, List<jpx> paramList, Context paramContext)
{
if (Build.VERSION.SDK_INT < 16) {
return;
}
Iterator localIterator = paramList.iterator();
ClipData localClipData = null;
while (localIterator.hasNext())
{
ClipData.Item localItem = new ClipData.Item(a(((jpx)localIterator.next()).e(), paramString, paramContext));
if (localClipData == null) {
localClipData = new ClipData(a, localItem);
} else {
localClipData.addItem(localItem);
}
}
paramIntent.setClipData(localClipData);
}
示例3: 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;
}
示例4: getClip
import android.content.ClipData.Item; //导入依赖的package包/类
@SuppressLint("NewApi")
public static String getClip(ClipboardManager cliper) {
try {
ClipData data = cliper.getPrimaryClip();
Item item = data.getItemAt(0);
return String.valueOf(item.getText());
} catch (Exception e) {
}
return null;
}
示例5: 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;
}
示例6: 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;
}