本文整理汇总了Java中android.support.annotation.StringRes类的典型用法代码示例。如果您正苦于以下问题:Java StringRes类的具体用法?Java StringRes怎么用?Java StringRes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StringRes类属于android.support.annotation包,在下文中一共展示了StringRes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: alert
import android.support.annotation.StringRes; //导入依赖的package包/类
/**
* Show an alert dialog to the user
* @param messageId String id to display inside the alert dialog
* @param optionalParam Optional attribute for the string
*/
@UiThread
void alert(@StringRes int messageId, @Nullable Object optionalParam) {
if (Looper.getMainLooper().getThread() != Thread.currentThread()) {
throw new RuntimeException("Dialog could be shown only from the main thread");
}
AlertDialog.Builder bld = new AlertDialog.Builder(this);
bld.setNeutralButton("OK", null);
if (optionalParam == null) {
bld.setMessage(messageId);
} else {
bld.setMessage(getResources().getString(messageId, optionalParam));
}
bld.create().show();
}
示例2: showLongSafe
import android.support.annotation.StringRes; //导入依赖的package包/类
/**
* 安全地显示长时吐司
*
* @param resId 资源Id
*/
public static void showLongSafe(@StringRes final int resId) {
sHandler.post(new Runnable() {
@Override
public void run() {
show(resId, Toast.LENGTH_LONG);
}
});
}
示例3: newInstance
import android.support.annotation.StringRes; //导入依赖的package包/类
public static TextInputDialogFragment newInstance(@StringRes int summary, TextInputDialogListener listener) {
TextInputDialogFragment f = new TextInputDialogFragment();
Bundle args = new Bundle();
args.putInt(SUMMARY_RES, summary);
f.setArguments(args);
f.mListener = listener;
return f;
}
示例4: setPositiveButton
import android.support.annotation.StringRes; //导入依赖的package包/类
@NonNull @Override
public BuilderJoinerAndroid setPositiveButton(
@StringRes int textId,
@Nullable DialogInterface.OnClickListener listener)
{
return (BuilderJoinerAndroid) super.setPositiveButton(textId, listener);
}
示例5: showShortSafe
import android.support.annotation.StringRes; //导入依赖的package包/类
/**
* 安全地显示短时吐司
*
* @param resId 资源Id
* @param args 参数
*/
public static void showShortSafe(final @StringRes int resId, final Object... args) {
sHandler.post(new Runnable() {
@Override
public void run() {
show(resId, Toast.LENGTH_SHORT, args);
}
});
}
示例6: onLoadingEmpty
import android.support.annotation.StringRes; //导入依赖的package包/类
public void onLoadingEmpty(@StringRes int error){
if (mTvError != null){
mTvError.setText(error);
mTvError.setVisibility(View.VISIBLE);
mProgressLoading.setVisibility(View.GONE);
mContainSubView.setVisibility(View.GONE);
}
}
示例7: suggest
import android.support.annotation.StringRes; //导入依赖的package包/类
/**
* Provide an array of suggestions to be shown while the user is typing
* This enables the auto-complete behaviour.
*
* @param suggestionStringResArray array of string resources to suggest
*/
public Input suggest(@StringRes int... suggestionStringResArray){
if (suggestionStringResArray != null && suggestionStringResArray.length > 0) {
this.suggestionStringResArray = suggestionStringResArray;
}
return this;
}
示例8: withUsageHintOnLongClick
import android.support.annotation.StringRes; //导入依赖的package包/类
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
public static Matcher<? super View> withUsageHintOnLongClick(@StringRes final int resourceId) {
return new TypeSafeMatcher<View>() {
private String resourceName;
private String expectedText;
@Override
protected boolean matchesSafely(View view) {
if (!view.isLongClickable()) {
return false;
}
expectedText = view.getResources().getString(resourceId);
resourceName = view.getResources().getResourceEntryName(resourceId);
if (expectedText == null) {
return false;
}
AccessibilityNodeInfo.AccessibilityAction clickAction = findAction(view, AccessibilityNodeInfo.ACTION_LONG_CLICK);
return expectedText.equals(clickAction.getLabel());
}
@Override
public void describeTo(Description description) {
description.appendText("is long clickable and has custom usage hint for ACTION_LONG_CLICK from resource id: ").appendValue(resourceId);
appendResourceNameAndExpectedTextToDescription(description, resourceName, expectedText);
}
};
}
示例9: showLong
import android.support.annotation.StringRes; //导入依赖的package包/类
@UiThread
public static void showLong(Context context, @StringRes int message) {
Toast toast = getToast(context);
if (toast != null) {
toast.setText(message);
toast.setDuration(Toast.LENGTH_LONG);
toast.show();
}
}
示例10: getThemeDialogAdapterItem
import android.support.annotation.StringRes; //导入依赖的package包/类
private static MaterialSimpleListItem getThemeDialogAdapterItem(@StringRes int title, @DrawableRes int icon, String currentTheme, Activity activity) {
MaterialSimpleListItem.Builder builder = new MaterialSimpleListItem.Builder(activity)
.content(title)
.icon(icon);
return builder.build();
}
示例11: setToolbarSubtitle
import android.support.annotation.StringRes; //导入依赖的package包/类
@Override
public void setToolbarSubtitle(@StringRes int titleRes, Object... params) {
ActionBar actionBar = ActivityUtils.supportToolbarFor(this);
if (Objects.nonNull(actionBar)) {
actionBar.setSubtitle(getString(titleRes, params));
}
}
示例12: getDialog
import android.support.annotation.StringRes; //导入依赖的package包/类
/**
* 单个按钮,显示需要调用show()
*
* @param context
* @param messageResId
* @param postBtResId
* @param postListener
*/
public static AlertDialog getDialog(final Context context, @StringRes int messageResId, @StringRes int postBtResId
, DialogInterface.OnClickListener postListener, boolean cancelable) {
AlertDialog dialog = new AlertDialog.Builder(context)
.setPositiveButton(postBtResId, postListener)
.setCancelable(cancelable)
.setMessage(messageResId)
.create();
return dialog;
}
示例13: showShort
import android.support.annotation.StringRes; //导入依赖的package包/类
@UiThread
public static void showShort(Context context, @StringRes int message) {
Toast toast = getToast(context);
if (toast != null) {
toast.setText(message);
toast.setDuration(Toast.LENGTH_SHORT);
toast.show();
}
}
示例14: newInstance
import android.support.annotation.StringRes; //导入依赖的package包/类
public static AwesomeDialogFragment newInstance(@StringRes int message, @StringRes int positive, @StringRes int negative) {
AwesomeDialogFragment fragment = new AwesomeDialogFragment();
Bundle bundle = new Bundle();
bundle.putInt(KEY_MESSAGE, message);
bundle.putInt(KEY_POSITIVE, positive);
bundle.putInt(KEY_NEGATIVE, negative);
fragment.setArguments(bundle);
return fragment;
}
示例15: showShortSafe
import android.support.annotation.StringRes; //导入依赖的package包/类
/**
* 安全地显示短时吐司
*
* @param resId 资源Id
*/
public static void showShortSafe(final @StringRes int resId) {
sHandler.post(new Runnable() {
@Override
public void run() {
show(resId, Toast.LENGTH_SHORT);
}
});
}