toast

第八次作业

心已入冬 提交于 2019-12-02 23:21:17
<?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:background="#E6E6E6" tools:context=".MainActivity"> <ImageView android:id="@+id/iv_head" android:layout_width="50dp" android:layout_height="50dp" android:layout_centerHorizontal="true" android:layout_marginTop="40dp" android:src="@drawable/dddss" /> <LinearLayout android:id="@+id/layout" android:layout_width="match_parent" android:layout_height="wrap

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

情到浓时终转凉″ 提交于 2019-12-02 23:15:41
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 . error1337 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) { $mdToast.show({ template: '<md-toast class="md-toast ' + type +'">' + msg + '</md-toast>', hideDelay:

Android 滑块验证

匿名 (未验证) 提交于 2019-12-02 22:56:40
先上图看看实现效果 1.在 app 的 build.gradle 添加依赖 implementation 'com.luozm.captcha:captcha:1.1.2' 2.将 Captcha 添加至布局文件 <com.luozm.captcha.Captcha android:id="@+id/captCha" android:layout_centerInParent="true" android:layout_width="match_parent" android:layout_height="265dp" android:layout_marginRight="10dp" android:layout_marginLeft="10dp" app:mode="mode_bar" app:src="@drawable/validate" app:blockSize="50dp" android:scaleType="centerCrop" app:max_fail_count="4"/> 3.添加 Java 代码 public void showw(String advPic) { Context context = MainActivity.this; diaa = new Dialog(context, R.style.edit_AlertDialog_style);

第8个作业

穿精又带淫゛_ 提交于 2019-12-02 19:22:08
package com.example.an2; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.HashMap; import java.util.Map; import android.content.Context; import android.content.SharedPreferences; public class SPSaveQQ { /** * 保存数据 * * @param context * @param account * @param password * @return */ public static boolean saveUserInfo(Context context, String account, String password) { SharedPreferences sp = context.getSharedPreferences("data", Context.MODE_PRIVATE); SharedPreferences.Editor edit = sp.edit(); edit

Error due to invalid combination of Toast and OnClickListener

烂漫一生 提交于 2019-12-02 17:04:00
I'm trying to use Toast inside OnCLickListener . My code triggers the following error: The method makeText(Context, CharSequence, int) in the type Toast is not applicable for the arguments (new View.OnClickListener(){}, String, int) This is my code: Button register = (Button) findViewById(R.id.register); register.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { EditText name = (EditText)findViewById(R.id.name); String Lname = name.getText().toString(); Toast.makeText(this, Lname, Toast.LENGTH_SHORT).show(); } }); As The Kenny said, this is refering to the View

作业8

巧了我就是萌 提交于 2019-12-02 15:43:41
<?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:background="#E6E6E6" tools:context=".MainActivity"> <ImageView android:id="@+id/iv_head" android:layout_width="50dp" android:layout_height="50dp" android:layout_centerHorizontal="true" android:layout_marginTop="40dp" android:src="@drawable/dddss" /> <LinearLayout android:id="@+id/layout" android:layout_width="match_parent" android:layout_height="wrap

Android中Toast的用法简介

流过昼夜 提交于 2019-12-02 15:34:25
Toast是Android中用来显示显示信息的一种机制,和Dialog不一样的是,Toast是没有焦点的,而且Toast显示的时间有限,过一定的时间就会自动消失。下面用一个实例来看看如何使用Toast。 1.默认效果 代码 Toast.makeText(getApplicationContext(), "默认Toast样式", Toast.LENGTH_SHORT).show(); 2.自定义显示位置效果 代码 toast = Toast.makeText(getApplicationContext(), "自定义位置Toast", Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); 3.带图片效果 代码 toast = Toast.makeText(getApplicationContext(), "带图片的Toast", Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER, 0, 0); LinearLayout toastView = (LinearLayout) toast.getView(); ImageView imageCodeProject = new ImageView(getApplicationContext())

Displaying a Toast notification in Android framework

时光总嘲笑我的痴心妄想 提交于 2019-12-02 14:41:10
问题 I'm trying to modify the Android framework by displaying an Toast notification in the PasswordUnlockScreen.java file when a password verification is done. I've added the following line of code in verifyPasswordAndUnlock() Toast.makeText(getApplicationContext(), "Verifying password", Toast.LENGTH_LONG).show(); However, I get the build error: frameworks/base/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java:166: cannot find symbol symbol : method getApplicationContext()

Toast inside a Button OnclickListener is not working [duplicate]

偶尔善良 提交于 2019-12-02 14:24:39
This question already has an answer here: I am trying to display a toast when this button is pressed. But the code is not working 3 answers intdelay was initialized at the beginning of the code by 1000 . and I am trying to make sure that intdelay 's value is updated by the value in the edit box by adding a toast when the button is clicked. but when I run the app, I get the following problem: Error:(46, 22) error: no suitable method found for makeText(<anonymous OnClickListener>,String,int) method Toast.makeText(Context,CharSequence,int) is not applicable (argument mismatch; <anonymous

Android广播机制

邮差的信 提交于 2019-12-02 12:10:19
一、简介 Android中的每个app都可以对自己感兴趣的广播进行注册,这样程序就只会接收到自己关心的广播内容,这些广播可能是来自系统的,也可能来自其他应用程序。发送广播要用到 Intent ,接收广播要用到 BroadcastReceiver 二、Android中广播的类型 1、标准广播 标准广播是一种 异步执行 的广播,在广播发出之后, 所有BroadcastReceiver几乎会在同一时刻接收到这条广播消息 ,因此它们之间没有先后顺序可言。 优点:效率高 缺点:无法截断 2、有序广播 有序广播是一种 同步执行 的广播,在广播发出之后, 同一时刻只会有一个BroadcastReceiver接收到这条消息 ,当这个BroadcastReceiver执行完毕之后,广播才会继续传递。 因此这种方式下,BroadcastReceiver是有先后顺序的,优先级高的BroadcastReceiver就能先收到广播消息,并且前面的BroadcastReceiver还可以截断广播,让后面的接收器无法收到。 三、如何接收广播 Android中有很多系统级别的广播,比如手机开机之后发出一条广播、电池电量变化会发出一条广播,我们可以在app中通过监听这些广播来得到系统的状态信息,要想接收这些广播,就得使用 广播接收器 。 广播接收器可以自由的对自己感兴趣的广播进行注册,当有相应的广播发出时