我制作了一些我可以使用Toast显示的字符串,但是我很难弄清楚如何使它们与单个Toast同时出现。到目前为止,我有这个:
String text = input.getText().toString();
String text2= input2.getText().toString();
String text3 = input3.getText().toString();
Toast.makeText(getApplicationContext(),"Name: " + text,Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(),"Age: " + text2,Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(),"Occupation: " + text3,Toast.LENGTH_SHORT).show();
当我运行模拟器时,它一次显示一个Toasts。有没有办法同时显示姓名,年龄和职业?
答案 0 :(得分:3)
将所有这些连接在一起。
Toast.makeText(getApplicationContext(),
"Name: " + text
+ " Age: " + text2
+ " Occupation: " + text3,
Toast.LENGTH_SHORT).show();
答案 1 :(得分:1)
试试这个:
Toast.makeText(this, "data = " +t_amount+ "" +order_no+ "" +ph_no, Toast.LENGTH_SHORT).show();
答案 2 :(得分:0)
尝试
String data = "Name: " + text + "\n" + " Age: " + text2 + "\n" + " Occupation: " + text3;
Toast.makeText(getApplicationContext(), data, Toast.LENGTH_LONG).show();