android-toast

Is it possible to get the value of string of Toast.makeText()?

江枫思渺然 提交于 2021-02-08 10:20:45
问题 If possible, I'd like to put the value of it to conditional statement (if) and put some arguments inside of it. 回答1: You can do like this: Toast myToast = Toast.makeText(this, "Hellow World!!!", Toast.LENGTH_SHORT); myToast.show(); //Now the statement below gets the text displayed String displayedText = ((TextView)((LinearLayout)myToast.getView()).getChildAt(0)).getText().toString(); 来源: https://stackoverflow.com/questions/33982322/is-it-possible-to-get-the-value-of-string-of-toast-maketext

show toast when there is no internet access android

谁说我不能喝 提交于 2021-01-28 07:46:59
问题 how do i make this code run in background forever and always detect if there is internet access or not (not internet connection) and show a toast when there is no internet access? here is what i want (See meow meo's answer), but it is for detecting internet // check connectivity (Internet access) private boolean checkConnectivity() { System.out.println("executeCommand"); Runtime runtime = Runtime.getRuntime(); try { Process mIpAddrProcess = runtime .exec("/system/bin/ping -c 1 8.8.8.8"); int

Android Toast Messages not working

你离开我真会死。 提交于 2020-02-21 13:16:57
问题 I'm developing a game via Andengine for Android. I have MainActivity class and GameScene class. I use Toast messages in GameActivity. And it is working. Toast.makeText(this, " Hello World", Toast.LENGTH_SHORT).show(); So I wanna use Toast messages in GameScene class. But it doesn't work. Here is the code: Toast.makeText(activity, " Hello World", Toast.LENGTH_SHORT).show(); I have to use "activity" instead of "this". But it doesn't work why? EDITED: when I use second one, an error occurs.

How to display Toast at center of screen

ε祈祈猫儿з 提交于 2020-01-30 14:03:10
问题 In Android I want to display a toast message at the bottom of the screen, I tried this: Toast.makeText(test.this,"bbb", Toast.LENGTH_LONG).show(); It doesn't work, how do I do it correctly? 回答1: To display the Toast in center of the screen. Toast toast = Toast.makeText(test.this,"bbb", Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); 回答2: Positioning your Toast A standard toast notification appears near the bottom of the screen, centered horizontally. You can change

Android WebView showToast onButtonClick

独自空忆成欢 提交于 2020-01-30 06:01:05
问题 I am developing an application that uses WebView to display a webpage. The webpage contains a registration form and a "next" button. I want to know if it is possible to show Android toast message if the users presses next, but has failed to fill the input areas or the data does not meet the required criteria. I have the validation logic written, but I am not sure about Toasts, can someone point me in the right direction? 回答1: You can solve your problem by implementing a simple JavaScript

Can not show Toast in OnItemClickListener inside Fragment

核能气质少年 提交于 2020-01-25 12:49:05
问题 I am trying to create a ListView in a Fragment . The listView appear correctly but when I complied the code shows error. import android.app.Fragment; import android.content.Context; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.Toast; public class ServiceFragment extends Fragment { private ListView

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); } })