[英]how do you get strings from the xml on the toast
how do i get my strings from the xml in on my toast 我如何从我的吐司中的xml中获取字符串
like 喜欢
<string name="Pic_taken">Billedet er nu blevet taget! </string>
in on this 在这个
Toast.makeText(getApplicationContext(), "Billedet er nu blevet taget!", Toast.LENGTH_SHORT).show();
像这样:
Toast.makeText(getApplicationContext(), getString(R.string.Pic_taken), Toast.LENGTH_SHORT).show();
just use the Toast API: 只需使用Toast API:
public static Toast makeText(Context context, @StringRes int resId, @Duration int duration)
公共静态Toast makeText(上下文上下文,@ StringRes int resId,@ Duration int持续时间)
Toast.makeText(getApplicationContext(), R.string.Pic_taken, Toast.LENGTH_SHORT).show();
Format: 格式:
Toast.makeText(Context context, @StringRes int resId, @Duration int duration);
So, for your case the code will be: 因此,对于您的情况,代码将是:
Toast.makeText(getApplicationContext(), R.string.Pic_taken, Toast.LENGTH_SHORT).show();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.