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