toast

Convert Toast message to text

别等时光非礼了梦想. 提交于 2019-12-31 03:10:31
问题 How can I convert this TOAST message to voice in Android? Example Toast.makeText(MainActivity.this, "I am enter code here" +positive[+ position]+ " always", Toast.LENGTH_SHORT).show(); 回答1: First import the package import android.speech.tts.TextToSpeech; Then initialize private TextToSpeech tts; tts = new TextToSpeech(this, this); Finally make a function like this private void speakOut() { String text = txtText.getText().toString(); tts.speak(text, TextToSpeech.QUEUE_FLUSH, null); } Woops. I

Toast notification isn't working?

谁说我不能喝 提交于 2019-12-31 01:49:01
问题 I'm following several examples to do a toast notification when I click a button in my app. I stepped through the following example: http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh868254.aspx I'm not getting any errors but when I run the application I don't get the toast notification. I have created a snippet here: http://codepaste.net/btkzeg ToastTemplateType toastTemplate = ToastTemplateType.ToastImageAndText01; XmlDocument toastXml = ToastNotificationManager.GetTemplateContent

Toast in a self running service

末鹿安然 提交于 2019-12-30 14:07:13
问题 I have an android activity which runs a remote service and then quits. The service itself, polls on a device node, and checks for changes, I want to use toast to alert the user, but I didn't mange to get it to work. the Toast is not showing, and after a while, Android shouts that my app is not responding. BTW, I don't want to start the activity again and display the toast from there, I just want it to pop on the current screen shown to the user. Here is the service code: public class

How to Customise Toast in Android?

一个人想着一个人 提交于 2019-12-30 06:17:10
问题 Is it possible to make Customize Toast in Android. like if can we place in it image icon and place button. 回答1: You can also use the regular makeText() and handle the getView() to set an image next to see the next. Toast toast = Toast.makeText(context, text, Toast.LENGTH_SHORT); TextView tv = (TextView) toast.getView().findViewById(android.R.id.message); if (null!=tv) { tv.setCompoundDrawablesWithIntrinsicBounds(icon, 0, 0, 0); tv.setCompoundDrawablePadding(context.getResources()

Showing Windows 8 toast from Windows Forms App

安稳与你 提交于 2019-12-30 03:20:09
问题 We've got a Windows Forms Application (vs. WPF) that was originally created for Windows 7. We're carrying the product forward to be used in Windows 8. Is it possible to show Windows 8 Toast Notifications (Windows.UI.Notifications namespace) from this WinForm app, for users running Windows 8? I can't seem to find any examples. Everything I find is a WPF or Windows Store apps—no examples are WinForm apps. 回答1: It is possible to use toast notification in winform poject under win 8. I create a

using a string resource in a Toast

我们两清 提交于 2019-12-29 08:30:10
问题 My code is: public static void ToastMemoryShort (Context context) { CharSequence text = getString(R.string.toast_memoryshort); //error here Toast.makeText(context, text, Toast.LENGTH_LONG).show(); return; } but I'm getting "Cannot make a static reference to the non-static method getString(int) from the type Context" in Eclipse. I'm trying to get ready for localising my app (getting all the hard coded strings into resources), so where I have: getString(R.string.toast_memoryshort) I previously

Android 选项菜单Option Menu 使用

一曲冷凌霜 提交于 2019-12-28 19:58:44
每个 Activity 都可以有至多一个选项菜单 菜单的视图文件最好在res下再新建一个目录存放,菜单视图文件名就是一个菜单资源标识 选项菜单的创建和使用 xml部分 <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:title="登录" android:id="@+id/login" /> <item android:title="注册" android:id="@+id/register" /> <item android:title="其他"> <menu> <item android:title="系统更新"/> <item android:title="设置"/> <item android:title="关于"/> </menu> </item> </menu> java部分 public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle

Detecting toast messages

眉间皱痕 提交于 2019-12-28 05:35:10
问题 I don't think this is possible, as I haven't found anything in the SDK documentation (yet). But I could do with knowing if its possible to write an application which logs Toast messages. Logging which application showed it and what the message displayed contained. This is an entirely personal endeavour to create an app which can detect the toast messages. Because something on my phone is creating a toast saying "Sending..." about once per day, and for the life of me I can't track down the

Open PDF in a WebView

。_饼干妹妹 提交于 2019-12-28 02:39:05
问题 I want to open a PDF in my WebView, and I found and combined codes on this forum. But it catches the "No PDF application found" although I have multiple PDF apps installed, including Adobe Reader. Here the code: private class PsvWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); if (url.contains(".pdf")) { Uri path = Uri.parse(url); Intent pdfIntent = new Intent(Intent.ACTION_VIEW); pdfIntent.setDataAndType

onPageFinished() never called (webview)!

[亡魂溺海] 提交于 2019-12-28 02:12:07
问题 I want to show a toast when the webview is totally loaded. But the toast never show up, i don't know why..here is my code: public class WebViewSignUp extends Activity{ WebView mWebView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.webviewsignup); mWebView = (WebView) findViewById(R.id.webview); mWebView.getSettings().setJavaScriptEnabled(true); ((TextView)findViewById(R.id.home)).setOnClickListener(new OnClickListener(