toast

“setView must have been called” - Custom Class extending button

房东的猫 提交于 2019-12-05 21:15:21
So I've got a 12 x 9 grid of "buttons" called "tiles". Tile.java extends the widget "Button". I've got an issue right now though, where I'm trying to get the button to display a toast that recalls the ID of the button pushed. The grid is added dynamically and I want it to stay that way. Here's the code from GameBoardActivity.java: This makes the 12x9 grid of "tiles" and adds a listener for each. public void gridRowButtons(int iterations){ final Tile[] gridSpaces = new Tile[12]; LinearLayout.LayoutParams buttonParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH

Toast not showing up in UnCaughtExceptionHandler

橙三吉。 提交于 2019-12-05 20:58:08
问题 I am using this code to handle any uncaught exceptions which might cause my application to crash. public class ExceptionHandler implements java.lang.Thread.UncaughtExceptionHandler { private final Context myContext; public ExceptionHandler(Context context) { myContext = context; } public void uncaughtException(Thread thread, Throwable exception) { Toast.makeText(myContext, "The application has crashed, and a report is sent to the admin", Toast.LENGTH_SHORT).show(); StringWriter stackTrace =

Adaptor控件类

二次信任 提交于 2019-12-05 20:21:14
Toast控件的使用 <RelativeLayout 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:gravity="center" android:background="#eeeeee"> <EditText android:text="" android:layout_height="70dp" android:hint="用户账号" android:layout_width="280dp" android:padding="20dp"> </EditText> <!--hintTextColor设置提示文字的样式 android:selectAllOnFocus="true"聚焦后全部选择里边的文字 android:password="true" 这个属性已经过时了只需要设置输入类型为密码就可以自动隐藏为幸好 也可以设置为日期数字等类型这样也会根据情况弹起相应的键盘 android

Android: Display a toast message after a custom time when a button is clicked

守給你的承諾、 提交于 2019-12-05 19:25:32
I want to add a toast say after 30 seconds when a button is clicked. Can you please help me out. nikis Something like that: Button button = new Button(this); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { Toast.makeText(context, "Hello!", Toast.LENGTH_LONG).show(); } }, 30000); } }); super-qua You can use a Handler with postDelayed() . You can find the documentation here For example: new Handler().postDelayed(new Runnable() { @Override public void

后端spring boot+前端Android交互+mysql增删查改

只愿长相守 提交于 2019-12-05 18:27:50
1.概述 使用spring boot作为后端框架与Android端配合mysql进行基本的交互,包含了最基本的增删查改功能. 2.开发环境 win10 IDEA tomcat9.0.27 mysql8.0.17 spring boot 3.后端 (1)新建一个spring boot项目 可以看这里 (2)Entity 新建User类作为实体类: package com.test; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; @Entity public class User { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Integer id; private String name; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getName() { return name; } public void

在活动中使用Toast和Menu

▼魔方 西西 提交于 2019-12-05 18:17:54
在创建的活动中使用Toast 在onCreate方法中添加以下代码 点击按钮,效果如图 在活动中使用Menu 首先在res目录下新建一个Menu文件夹,接着在中国文件夹下创建一个名为main的菜单文件 然后在main.xml中添加以下代码 接着在FirstActivity中重写onCreateOptionsMenu()方法 然后在FirstActivity中重写onOptionsItemSelect()方法 重新运行程序,标题栏右侧有一个三点的符号,这就是菜单按钮 来源: https://www.cnblogs.com/ccffhh/p/11939366.html

转:android获取存储目录(路径)的几种方式和注意事项

早过忘川 提交于 2019-12-05 17:46:03
转自: https://blog.csdn.net/yan_startwith2015/article/details/77931389 android获取存储目录(路径)的几种方式和注意事项 2017年09月11日 11:42:09 阅读数:5807 通常, 我们创建文件/目录, 或者存储图片什么的, 我们都需要拿到手机的存储路径, 现在我们就来看一下获取手机存储路径的几种方式(作为工具类方法调用即可): 第一种: 获取 /storage/emulated/0 public static boolean sdCardIsAvailable() { //首先判断外部存储是否可用 if (Environment.getExternalStorageState().equals(Environment. MEDIA_MOUNTED )) { File sd = new File(Environment.getExternalStorageDirectory().getPath () ); Log.e("qq", "sd = " + sd);//sd = /storage/emulated/0 return sd.canWrite(); } else { return false; } 第二种: 获取 /storage/emulated/0(类似上面) public String

android获取存储目录(路径)的几种方式和注意事项

拜拜、爱过 提交于 2019-12-05 17:41:02
通常, 我们创建文件/目录, 或者存储图片什么的, 我们都需要拿到手机的存储路径, 现在我们就来看一下获取手机存储路径的几种方式(作为工具类方法调用即可): 第一种: 获取 /storage/emulated/0 public static boolean sdCardIsAvailable () { //首先判断外部存储是否可用 if ( Environment . getExternalStorageState (). equals ( Environment . MEDIA_MOUNTED )) { File sd = new File ( Environment . getExternalStorageDirectory (). getPath () ); Log . e ( "qq" , "sd = " + sd); //sd = /storage/emulated/0 return sd. canWrite (); } else { return false ; } 第二种: 获取 /storage/emulated/0(类似上面) public String getSDPath () { File sdDir = null ; //判断sd卡是否存在 boolean sdCardExist = Environment . getExternalStorageState

Toast notification & Geofence Windows Phone 8.1

拜拜、爱过 提交于 2019-12-05 17:05:18
I'm facing a strange problem with my Windows Phone 8.1 App. The App will send a toast notification every time the user is near a Point of his interest using Geofence Quickstart: Setting up a geofence and BackgroundTask Quickstart: Listening for geofence events in the background And this is the Background task (example) public void Run(IBackgroundTaskInstance taskInstance) { // Get the information of the geofence(s) that have been hit var reports = GeofenceMonitor.Current.ReadReports(); var report = reports.FirstOrDefault(r => (r.Geofence.Id == "id") && (r.NewState == GeofenceState.Entered));

Windows 10 Toast Notifications Desktop Application

与世无争的帅哥 提交于 2019-12-05 16:28:30
问题 I'm trying to integrate some Windows 10 features into my existing Windows Desktop application. I am a little stuck integrating the Toast Notifications. Using the toast notification example (https://code.msdn.microsoft.com/windowsdesktop/sending-toast-notifications-71e230a2/) I was able to implement code to send and hide notifications. It also works, that when the user clicks on an 'active' notification an event handler in my application is invoked. However, as soon as the notification is