LayoutInflater layInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View showBackView = layInflater.inflate(R.layout.nd_banner_layout,null);
TextView backText = (TextView)showBackView.findViewById(R.id.nd_banner_title);
backText.setText(String.format(getResources().getString(R.string.nd_banner_title_format) , nickName ));
Toast toast = new Toast(CityActivity.this);
toast.setGravity(Gravity.TOP, 20, 40);
toast.setDuration(25000);
toast.setView(showBackView);
toast.show();
XML自定义drawable之后的使用法方法
显示自定义Toast
最新推荐文章于 2025-12-09 22:00:29 发布
本文介绍了一种使用LayoutInflater从布局文件加载视图,并将其设置为Toast显示的方法。具体步骤包括通过getSystemService获取LayoutInflater实例,inflate方法加载指定布局资源,findViewById设置TextView内容,创建Toast并设置其属性如位置、持续时间和显示视图。
534

被折叠的 条评论
为什么被折叠?



