Tag: toast

Android中的文本中心文本

我想知道是否有一种方法来显示所有的文字在敬酒中心。 例如,我有一个有两行文字的祝酒词。 出于纯粹的美学原因,我希望文本中心alignment,而不是左alignment。 我查看了文档,找不到任何关于它的信息。 有没有简单的方法来做到这一点,我错过了? 谢谢Chris

在片段内使用烤面包片

当用户点击Fragment中的button时,我试图显示Toast消息。 问题是我无法访问该活动,以显示其吐司。 这里是Fragment的来源: public class FrgTimes extends Fragment { ScrollView sv; public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (container == null) { return null; } sv = (ScrollView)inflater.inflate(R.layout.frg_times, container, false); btnTime1.setOnClickListener(new OnClickListener() { public void onClick(View v) { //****** HERE's the PROBLEM ******** Toast.makeText(<The Activity>, "Please long press the key", Toast.LENGTH_LONG ); […]

在android espresso中检查toast消息

谁会知道如何testing在Android的咖啡吐司消息的外观? 在机器人中,它使用起来很简单,但是开始使用浓缩咖啡,但没有得到确切的命令。

Android:如何设置Toast文本的颜色

我使用以下代码作为if语句的结果显示吐司消息: Toast.makeText(getBaseContext(),“请input价格”,Toast.LENGTH_SHORT).show(); 它在白色背景上显示为白色文字,因此无法阅读! 我的问题是,我怎样才能改变吐司文字的颜色?

如何在Android中显示Toast?

我有一个滑块,可以拉起来,然后显示一张地图。 我可以上下移动滑块来隐藏或显示地图。 当地图在前面时,我可以在该地图上处理触摸事件。 每当我触摸,一个AsyncTask被启动,它下载一些数据,并使一个Toast显示数据。 尽pipe我在触摸事件上启动任务,但是没有显示出烤面包,直到我closures滑块。 当滑块closures,地图不再显示时, Toast就会出现。 有任何想法吗? 那么开始这个任务吧 编辑: public boolean onTouchEvent(MotionEvent event, MapView mapView){ if (event.getAction() == 1) { new TestTask(this).execute(); return true; }else{ return false; } } 并在onPostExecute做一个敬酒 Toast.makeText(app.getBaseContext(),(String)data.result, Toast.LENGTH_SHORT).show(); 在新的TestTask(this) ,这是对MapOverlay的引用,而不是MapActivity ,所以这就是问题所在。

在AsyncTask中获取上下文

我正在尝试获取名为Opciones的类的AsyncTask中的上下文(这个类是唯一一个调用这个任务的),但我不知道该怎么做,我看到了这样的代码: protected void onPostExecute(Long result) { Toast.makeText(Opciones.this,"Subiendo la foto. ¡Tras ser moderada empezara a ser votada!: ", Toast.LENGTH_LONG).show(); } 但它不适用于我说: "No enclosing instance of the type Opciones in scope"

不能在没有调用Looper.prepare()的线程中创build处理程序

以下例外是什么意思; 我该如何解决? 这是代码: Toast toast = Toast.makeText(mContext, "Something", Toast.LENGTH_SHORT); 这是例外: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() at android.os.Handler.<init>(Handler.java:121) at android.widget.Toast.<init>(Toast.java:68) at android.widget.Toast.makeText(Toast.java:231)