toast

Can't toast on a thread that has not called Looper.prepare()

人盡茶涼 提交于 2019-12-05 14:46:05
Android开发中Can't toast on a thread that has not called Looper.prepare()问题 说一下问题出现场景:   在一个Android项目中,利用okhttp进行网络访问判断用户输入的账号密码,当用户密码输错时弹出 Toast 进行提示。 截取部分代码如下: 利用okhttp进行网络访问代码(其中User类是用来包装用户名和密码): import com.hzau.xiaonongfu.Entity.User; import okhttp3.*; public class HttpUtil { private static final String TAG="HttpUtil"; private static final OkHttpClient client=new OkHttpClient().newBuilder().build(); //用户登录验证 public static void login(User user,okhttp3.Callback callback){ //建立表单,添加需要上传到服务器的参数 RequestBody body=new FormBody.Builder() .add("username",user.getUser_name()) .add("password",user

组件化设计:弹窗的使用逻辑

*爱你&永不变心* 提交于 2019-12-05 14:06:27
首先梳理一下弹窗的类别,根据其使用场景,可以归为 模态 跟 非模态 ,也称之为阻断式和非阻断式,评判标准在于是否打断用户操作。 弹窗的作用在于,在用户进行页面操作时,中断其操作,或反馈相应的信息,或是当前内容的补充,帮助用户进行下一步操作,是处理页面中的即时任务的重要功能。 模态弹框 一般出现于页面中时,用户需要与之操作,页面层级很高,能直接吸引用户的关注,但同时会中断用户操作,因此在页面设计中不能滥用。比如对话框(Dialog / Allert)、浮层(Popover)、操作栏(Action bar)。 非模态框 在页面中表现得更轻盈,它能即时的给予反馈,但又不会干扰用户,从出现到消失的时间都很短。比如有吐司(Hud / Toast)和通知条(Snack bar),Hud / Toast 是分别属于ios 和 android 系统的控件,他们的表现形式基本一样,可以归为一类组件,页面中常见的半透明矩形提示就是以Toast 的 形式出现居多。 来源: https://www.cnblogs.com/wangqian888/p/11926680.html

Android--------自定义toast

时间秒杀一切 提交于 2019-12-05 11:14:44
布局文件: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/toast_layout_root" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#DAAA" android:orientation="horizontal" android:padding="8dp" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="8dp" android:src="@drawable/ic_launcher" /> <TextView android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFF" /> </LinearLayout> java代码: import android

Toast Notification issue with recent device update in Android

微笑、不失礼 提交于 2019-12-05 10:13:01
This post is related to the existing filed bug: https://groups.google.com/forum/#!topic/android-developers/K7pjy3Gm5Lk/discussion Apparently, in some devices after a system update, the toasts are not shown. The problem happens when in preferences, for your application the notifications checkbox is unchecked. Due to that your all the toasts of your app will be hidden. This happened to me on a Samsung galaxy tab 2 but it can happen on other devices: Toast Notifications Not Showing Up on Nexus 7 Tablet or on SGS3 as commented on the google group link. I don't know if this happens on all devices

2019双十一淘宝天猫刷喵币

混江龙づ霸主 提交于 2019-12-05 08:07:27
实现步骤 下载并安装Auto.js 官网网址:https://hyb1996.github.io/AutoJs-Docs Github地址:https://github.com/hyb1996/Auto.js 不过我知道因为什么原因资源被酷安下架了,所以附上Auto.js的安装包在我的下载里. 为软件打开无障碍权限. 在软件中将脚本保存并运行即可,脚本会自己打开手机淘宝并进行一系列的操作. 脚本内容 11.7号更新 auto . waitFor ( ) var appRun = currentActivity ( ) var t = 0 if ( appRun != 'com.taobao.taobao' ) { launchApp ( "手机淘宝" ) toast ( "打开手机淘宝中" ) ; sleep ( 5000 ) } function run ( ) { className ( "android.view.View" ) . desc ( "搜索" ) . clickable ( true ) . findOne ( ) . click ( ) sleep ( 2000 ) id ( "searchEdit" ) . waitFor ( ) sleep ( 500 ) id ( "searchEdit" ) . findOne ( ) . setText (

Change text and icon in a Custom Toast?

左心房为你撑大大i 提交于 2019-12-05 06:41:53
问题 I'm having some issues when I trying to show a custom toast (with icon and message). This is the code. private void makeToast(String text, int icon) { LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.custom_toast,(ViewGroup) findViewById(R.id.message)); ((TextView) layout.findViewById(R.id.message)).setText(text); layout = inflater.inflate(R.layout.custom_toast,(ViewGroup) findViewById(R.id.icon)); // 0 - Exclamation, 1 - Noow icon if(icon == 0){ (

作业9

元气小坏坏 提交于 2019-12-05 06:04:04
<?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" tools:context="com.example.myapplication.MainActivity"> <LinearLayout android:id="@+id/linearlayout1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="140dp" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="姓名:" android:textSize="55px

Display two Toast messages at once?

落花浮王杯 提交于 2019-12-05 05:16:44
I would like one Toast message to display in one location and a different Toast message to display in another location simultaneously. Multiple Toast messages seem to always queue and display in order. Is it possible to show both messages at the same time? Is there a workaround that at least gives that appearance and doesn't involve messing with the activity layout? Edit: It seems the answer to the first question is no, it's not possible. How about a workaround? A solution for me would include something that appears "over" the app like a Toast and doesn't interfere with user interaction with

Suppressing toast from package in Android

心不动则不痛 提交于 2019-12-05 03:52:04
I'm developing an Android app and I'm trying to show some information with a Toast . I used Toast s in other projects and everything works, but in this app, when the Toast should appear, it doesn't do it and Logcat shows the next message: Suppressing toast from package com.xxxxxxx by user request. I'm creating the toast with the next code: Context context = xxxxxxx.this; CharSequence text = "Hello toast!"; int duration = Toast.LENGTH_SHORT; Toast toast = Toast.makeText(context, text, duration); toast.show(); I tried to set the context with getApplicationContext() and getBaseContext() too, but