toast

Android: Show toast after finishing application / activity

岁酱吖の 提交于 2019-12-01 18:34:36
问题 I want to show a simple toast, when exiting an application. The problem is, that the toast is not shown. I assume it is because the acitivity is finished or because of System.exit(0) , but I don't know how to solve it. Does anyone have a tip? Thanks!! In my activity I have the following code: Toast.makeText(this,"Exit application.",Toast.LENGTH_SHORT).show(); exitApp(); public void exitApp (){ App.getInstance().exit(); finish(); } And the mehod exit in App: public void exit() { System.exit(0)

12.1 网格listview 点击事件

南笙酒味 提交于 2019-12-01 18:25:39
实现界面: 事件:当点击时可以出现点击事件 实现思路,图片下面有一个文本框,又要以网格的形式实现界面, 那么就需要使用girdview完成网格布局, 同时使用一个打气筒将一个layout转成一个view, xml: main <?xml version="1.0" encoding="utf-8"?> <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" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.example

APP 反馈的三种形式:toast、snackbar、dialog

感情迁移 提交于 2019-12-01 15:21:06
APP 反馈的三种形式:toast、snackbar、dialog 聪明的产品会在恰当的时间给予恰当的反馈,不反馈、反馈不及时、反馈不对都会让用户反感你的产品,从而失去用户。 现在的公司是做软硬件一体化,我负责OS层面的交互方案,这里会遇到要制定一些设计原则,从而让产品体验更统一。我们都知道,针对信息提醒,有一种设计形式叫toast,如何对toast进行规范,引发了我写这篇文章。 1.反馈 互联网产品存在两套反馈机制,一套是有明显界面变动的反馈,例如你点击淘宝列表页,立马就进入了商品详情页,页面的及时跳转是明显的视觉反馈;再比如你输入完账号密码,点击登录,登录成功,并进入了APP首页,这也是很明显的视觉反馈。 但,如果某种反馈不明显该怎么办?例如,你登录的时候你输错了账号密码,点击登录,是进入不了APP的,这个时候大部分产品都会给予toast提示用户:密码或账号输入错误,请重试。你看到这个提示之后,就会知道自己改怎么做了。这就是反馈的第二套机制:通过设计不同的形式来提示用户。 常见的反馈有三种样式:toast、snackbar、dialog。 2.Toast toast属于一种轻量级的反馈,常常以小弹框的形式出现,一般出现1到2秒会自动消失,可以出现在屏幕上中下任意位置,但同个产品会模块尽量使用同一位置,让用户产生统一认知。 在样式上,尽量和产品整体风格保持一致,这样会更和谐

Based on JSON data..How to Toast server Status at doInBackground form a Service

久未见 提交于 2019-12-01 14:51:11
I am trying to Show Toast on Server Status These are my Types of JSONdata from Server 1) { "status": "200", "response": { "SortAs": "SGML", "GlossTerm": "Standard Generalized Markup Language", "Acronym": "SGML", "Abbrev": "ISO 8879:1986", . .. . } } 2) { "status": "204", "response": { "msg": "No Content" } } 3) { "status": "401", "response": { "msg": "Unauthorized User" } } So Now Here I want to Toast Data to the User wen I got Status as 204 or 401 etc I tried with @Override protected Void doInBackground(Void... arg0) { HttpServiceClass httpServiceClass = new HttpServiceClass(HttpJSonURL); try

Based on JSON data..How to Toast server Status at doInBackground form a Service

北城余情 提交于 2019-12-01 14:21:43
问题 I am trying to Show Toast on Server Status These are my Types of JSONdata from Server 1) { "status": "200", "response": { "SortAs": "SGML", "GlossTerm": "Standard Generalized Markup Language", "Acronym": "SGML", "Abbrev": "ISO 8879:1986", . .. . } } 2) { "status": "204", "response": { "msg": "No Content" } } 3) { "status": "401", "response": { "msg": "Unauthorized User" } } So Now Here I want to Toast Data to the User wen I got Status as 204 or 401 etc I tried with @Override protected Void

`Can't create handler…Looper.prepare()` in inherited Activity

☆樱花仙子☆ 提交于 2019-12-01 13:05:35
I have a Game Activity (Activity A) that works well with all the code. Then I create a new Activity (Activity B) for my new game mode, that extends Activity A. However, when encounter the Toast line, Activity B suddenly thrown an exception (Activity A works well showing the Toast): Can't create handler inside thread that has not called Looper.prepare() Activity B only overrides a load-level method, no any differrence! Try this: Handler innerHandler; (new Thread(new Runnable() { @Override public void run() { Looper.prepare(); innerHandler = new Handler() { @Override public void handleMessage

Android add custom animation to Toast

半城伤御伤魂 提交于 2019-12-01 10:43:25
I need to create a custom animated toast message. Now i need to know if that is possible. I've created a toast with a custom view but I cannot figure out how can I add custom animation to the toast. Here is the code I have so far. private void showToast() { LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.custom_toast, (ViewGroup) findViewById(R.id.custom_toast_layout_id)); // set a message TextView text = (TextView) layout.findViewById(R.id.toast_text); text.setText("Button is clicked!"); // Toast... Toast toast = new Toast(getApplicationContext()); toast

`Can't create handler…Looper.prepare()` in inherited Activity

China☆狼群 提交于 2019-12-01 10:39:17
问题 I have a Game Activity (Activity A) that works well with all the code. Then I create a new Activity (Activity B) for my new game mode, that extends Activity A. However, when encounter the Toast line, Activity B suddenly thrown an exception (Activity A works well showing the Toast): Can't create handler inside thread that has not called Looper.prepare() Activity B only overrides a load-level method, no any differrence! 回答1: Try this: Handler innerHandler; (new Thread(new Runnable() { @Override

Android add custom animation to Toast

浪尽此生 提交于 2019-12-01 09:34:17
问题 I need to create a custom animated toast message. Now i need to know if that is possible. I've created a toast with a custom view but I cannot figure out how can I add custom animation to the toast. Here is the code I have so far. private void showToast() { LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.custom_toast, (ViewGroup) findViewById(R.id.custom_toast_layout_id)); // set a message TextView text = (TextView) layout.findViewById(R.id.toast_text);

Toast notification response in background task

安稳与你 提交于 2019-12-01 07:55:28
问题 I'm writing an application which can show toast notifications in a background task (I use BackgroundTaskBuilder) . In the notification I'm using two button, which should do two different function, but I can't get the notification's response. I read on the internet that I should start another background task for this, but I can't start another background task in a backround task. So my question is: How can I get that the user what button clicked in the notification? Thanks for the help. 回答1: