toast

How to toast a message for a specific time period?

廉价感情. 提交于 2020-01-06 12:53:25
问题 I have made some code for my google map, where I position the camera to one place when the camera is positioned to the first place I toast a message and then I move the camera to another position but the problem is that the toast action doesn't appear for enough time in order to read the message. Is there anyway so I can set the toast lets say for 10 seconds or so ? Here is my code. public void onFinish() { LatLng 1= new LatLng(x , y); LatLng 2= new LatLng(x , y); GoogleMap map = (

getString and DialogListener doesn't work after class switch

允我心安 提交于 2020-01-06 07:29:24
问题 I want to start an activity and give out a Toast message after I parsed a JSON response, well as you can't do that while a Dialog is open, I am using a DialogListener, which actually works fine, but not when it gets called in the parseJSON method. public class Pop_Forgot_PW extends AppCompatDialogFragment{ ...... sendResetMail(); private void sendResetMail() { final String url = "someURL"; new Json(new Json.Callback() { @Override public void run(String result) { parseJSON(result); } })

Android - My Simple ListView/Toast app crashes on startup… any ideas?

試著忘記壹切 提交于 2020-01-06 01:55:16
问题 I am creating a simple ListView app to learn more about programming for android. However, this simple code (which is showing no errors whatsoever in Eclipse) is simply crashing on startup in the emulator. Any ideas? public class MainActivity extends Activity { static final String[] FRUITS = { "Apple", "Avocado", "Banana", "Blueberry", "Coconut", "Durian", "Guava", "Kiwifruit", "Jackfruit", "Mango", "Olive", "Pear", "Sugar-apple" }; protected void onCreate(Bundle savedInstanceState) { super

Toast doesn't disappear from screen

删除回忆录丶 提交于 2020-01-05 03:59:05
问题 I have a problem with my simple android aplication that use GPS cords. My class MyLocationListener implements LocationListener, and there is a static method call: String strText ="My current location is: " + "Latitude = " + location.getLatitude() + " Longitude= " + location.getLongitude(); Toast.makeText(GpsModule.cont, strText, Toast.LENGTH_SHORT).show(); Problem is with displaying this string. It's showing up, and never ends. When I press back button for main menu and even when I close

How can I put Toast in a Runnable of a Service?

情到浓时终转凉″ 提交于 2020-01-05 03:52:11
问题 I have a service which contains a Timer and TimerTask for receiving data from Webservice in periods of time. everything works fine except Toast. I want to show a Toast to user in procSendMapMovements but i get exception. How can I use Toast in it? class taskSendMapMovements extends TimerTask { @Override public void run() { hhSendMapMovements.sendEmptyMessage(0); } }; // ///////////////////// final Runnable rSendMapMovements = new Runnable() { public void run() { procSendMapMovements(); } };

Android: Toast from IntentService remains on screen for ever

*爱你&永不变心* 提交于 2020-01-02 07:32:33
问题 I checked this question, but it doesn't appear to answer my problem, which is much less involved. I am calling an IntentService from a menu item in my main process. It is currently just a skeleton which puts up a Toast in onHandleIntent() which eventually should appear briefly at the end of the processing to say it's finished. However it remains on the screen for ever (even when the application is stopped). I tested both with the emulator and my Galaxy S2 with identical results. Can someone

Display two Toast messages at once?

本小妞迷上赌 提交于 2020-01-02 02:36:08
问题 I would like one Toast message to display in one location and a different Toast message to display in another location simultaneously. Multiple Toast messages seem to always queue and display in order. Is it possible to show both messages at the same time? Is there a workaround that at least gives that appearance and doesn't involve messing with the activity layout? Edit: It seems the answer to the first question is no, it's not possible. How about a workaround? A solution for me would

Android Button的基本使用

核能气质少年 提交于 2020-01-01 23:38:56
title: Android Button的基本使用 tags: Button,按钮 --- Button介绍: Button(按钮)继承自TextView,在Android开发中,Button是常用的控件,用起来也很简单,你可以在界面xml描述文档中定义,也可以在程序中创建后加入到界面中,其效果都是一样的。不过最好是在xml文档中定义,因为一旦界面要改变是话,直接修改一下xml就行了,不用修改Java程序,并且在xml中定义层次分明,一目了然。 Button 支持的 XML 属性及相关方法 XML 属性 相关方法 说明 android:clickable setClickable(boolean clickable) 设置是否允许点击。 clickable=true:允许点击 clickable=false:禁止点击 android:background setBackgroundResource(int resid) 通过资源文件设置背景色。 resid:资源xml文件ID 按钮默认背景为android.R.drawable.btn_default android:text setText(CharSequence text) 设置文字 android:textColor setTextColor(int color) 设置文字颜色 android:onClick

Error due to invalid combination of Toast and OnClickListener

99封情书 提交于 2019-12-31 08:34:09
问题 I'm trying to use Toast inside OnCLickListener . My code triggers the following error: The method makeText(Context, CharSequence, int) in the type Toast is not applicable for the arguments (new View.OnClickListener(){}, String, int) This is my code: Button register = (Button) findViewById(R.id.register); register.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { EditText name = (EditText)findViewById(R.id.name); String Lname = name.getText().toString(); Toast

Toast inside a Button OnclickListener is not working [duplicate]

心已入冬 提交于 2019-12-31 07:43:24
问题 This question already has answers here : I am trying to display a toast when this button is pressed. But the code is not working (3 answers) Closed 3 years ago . intdelay was initialized at the beginning of the code by 1000 . and I am trying to make sure that intdelay 's value is updated by the value in the edit box by adding a toast when the button is clicked. but when I run the app, I get the following problem: Error:(46, 22) error: no suitable method found for makeText(<anonymous