toast

android image button tooltip

匿名 (未验证) 提交于 2019-12-03 08:41:19
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to build an app with image buttons that work like the action bar but i can't get them to show a tooltip on long press. <ImageButton android:id="@+id/editUrgent" style="?android:attr/borderlessButtonStyle" android:layout_width="48dp" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_toLeftOf="@+id/editImportant" android:hint="@string/hint_urgent" android:contentDescription="@string/hint_urgent" android:text="@string/hint_urgent" android:src="@drawable/clock_light" /> android:contentDescription

File contains a path separator.

匿名 (未验证) 提交于 2019-12-03 08:36:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: When I try to check the existence of a particular file, I get java.lang.illegalArgumentException: File contains a path separator What is the right way to do this using getFileStreamPath(..)? File file = getActivity().getFileStreamPath("mnt/sdcard/photo/1342147146535.jpg"); if(file.exists()){ Toast.makeText(getActivity(), "File exists in /mnt", Toast.LENGTH_SHORT); } I also tried the following to replace the first line of the above codes. None of these worked. File file = getActivity().getFileStreamPath("file:///mnt/sdcard/photo/aviary

How to cancel Toast

匿名 (未验证) 提交于 2019-12-03 08:30:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I developed an android application and I am facing a problem with Toast . Suppose I am displaying a Toast, it is displayed on the application window. When a Dialog box is appears, the toast doesn't disappear instantly . I want to know how I can cancel the toast. 回答1: Toast.makeText returns a Toast object. Call cancel() on this object to cancel it. 回答2: The shortest duration you can specify for the toast is Toast.LENGTH_SHORT which has a value of 0 but is actually 2000 milliseconds long . If you want it shorter than that, then try this: final

转盘抽奖的实现

夙愿已清 提交于 2019-12-03 08:09:42
如图效果展示:(因最近双十一,公司需求要给新老客服抽奖发福利,临时写的) 核心代码: async rotating() { var type = 0; // 默认为 0 转盘转动 1 箭头和转盘都转动(暂且遗留) var during_time = 5; // 默认为1s var result_index = this.index-1; // 最终要旋转到哪一块,对应prize_list的下标 var result_angle = [190 ,139 ,88 ,37 ,-14,-65 ,-116] //这里是指定位置 var rand_circle = 6; // 附加多转几圈,2-3 var rotate_angle = 0; this.count++ if (type == 0) { // 转动盘子 var rateround=rand_circle * 360 + result_angle[result_index] //这里是(转盘算法) rateround是转动的距离 this.start_rtating是每次初始化转盘的位置 rotate_angle =this.start_rotating_degree + rateround -this.start_rotating_degree % 360 ; this.start_rotating_degree = rotate

how can I change the color of Toast depends on message type in Angular material $mdToast?

霸气de小男生 提交于 2019-12-03 08:04:23
问题 While using $mdToast.simple().content("some test") it is showing the toast with black color. how can I change that color to red, yellow and so, depends on the type of the error messages like error, warning and success. Similar question as this. 回答1: EDIT: For a correct implementation, please use rlay3s solution below :)! OUTDATED: I had problems displaying custom text with jhblacklocks solution, so I decided to do it like this using 'template': var displayToast = function(type, msg) {

Custom Toast Cancel not working

断了今生、忘了曾经 提交于 2019-12-03 07:52:21
I have seen a number of questions on cancelling toast. None of them is working. I have a custom Toast. The code for that is all but one line same as http://developer.android.com/guide/topics/ui/notifiers/toasts.html#CustomToastView The difference is as follows. The toast variable is defined as a class variable The entire java code is written in a method. In the start of this method, I have added the following line to cancel the toast. if (toast!=null){ toast.cancel(); } The method is called when user selects (onClick) the view/layout. The issue is when the user selects few times, the toast

Android Studio music player cant read from sdcard, only internal memory

匿名 (未验证) 提交于 2019-12-03 07:50:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I apologize if this turns out to be a stupid question, it might turn out as a quick fix but I just cant figure it out. I'm building a music player in android studio and none of the songs on the sdcard dont show up in the list view, only the ones in internal memory, even though I did implement getExternalStorageDirectory() and added the permission in the manifest file. Any input on this or constructive criticism is greatly apreciated. Here is the main java class. public class MainActivity extends AppCompatActivity { ListView lv; String[]

Android Set the text align to the middle of the toast [duplicate]

匿名 (未验证) 提交于 2019-12-03 07:36:14
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This question already has an answer here: Center text in a toast in Android 11 answers I have a toast message which is pretty long. I would like to set the text in the middle and not to start align to the left. Is this possible? 回答1: Toast is built on a TextView and the default gravity of it is left aligned. So, you need to create your own TextView like this for instance : <TextView android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center_vertical|center_horizontal" android:text="all the text you want" /

How to create toast in phonegap?

不羁的心 提交于 2019-12-03 05:04:41
问题 How to create toast in android application using phonegap / cordova? Thanx! 回答1: First create a ToastPlugin.java package com.company.plugins; import org.apache.cordova.api.CallbackContext; import org.apache.cordova.api.CordovaPlugin; import org.json.JSONArray; import org.json.JSONException; import android.util.Log; import android.widget.Toast; public class ToastPlugin extends CordovaPlugin { @Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext)

作业九

☆樱花仙子☆ 提交于 2019-12-03 05:01:16
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" android:padding="16dp" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="130dp" android:orientation="horizontal" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="姓 名:" android:textSize="18sp" /