Blankj / AndroidUtilCode

:fire: Android developers should collect the following utils(updating).
https://blankj.com/2016/07/31/android-utils-code/
Apache License 2.0
33.32k stars 10.69k forks source link

关于自定义toast view #264

Closed sooner0493 closed 7 years ago

sooner0493 commented 7 years ago

private static void show(CharSequence text, int duration) { cancel(); if (customView != null) { sToast = new Toast(Utils.getContext()); sToast.setView(customView); sToast.setDuration(duration); } else { sToast = Toast.makeText(Utils.getContext(), text, duration); } sToast.setGravity(gravity, xOffset, yOffset); sToast.show(); } 请问这个如何设置显示的text内容?谢谢

Blankj commented 7 years ago

?不知道你在说什么

sooner0493 commented 7 years ago

抱歉 没表达清 我是说自定义view时传入的layout里面有TextView,如何给这个TextView赋值呢 ?

Blankj commented 7 years ago

getView().findViewById(id)

sooner0493 commented 7 years ago

是这样? ((TextView) ToastUtils.getView().findViewById(R.id.message)).setText(words); ToastUtils.showShort(words);

Blankj commented 7 years ago
ToastUtils.showCustomLong(R.layout.toast_custom);
TextView tvMessage = (TextView) ToastUtils.getView().findViewById(R.id.tv_toast_message);
tvMessage.setText(getString(R.string.toast_custom_view));
sooner0493 commented 7 years ago

好吧 谢谢。。。