一个android.widget.EditText可以通过2个原因获得焦点,因为我知道:
案例1.最终用户按目的触摸编辑文本.
案例2.系统自动提供编辑文本.
我的问题是: 如何才能检测到案例2?(事件监听器?)
我想要检测案例2的原因是:我想设置当前位置是编辑文本通过案例2获得焦点的最后位置.
EditText.setOnFocusChangeListener适用于case1,case2所以看来我不能使用它.
谢谢!
我有一个textView,可以显示任何语言的文本(最终用户输入文本).
我想知道我应该使用什么字体?
在本文中:http://www.google.com/design/spec/style/typography.html#typography-roboto-noto
谷歌说:
为了支持全球所有语言,Google建议将Roboto用于使用拉丁语,希腊语和西里尔语脚本的语言,将Noto用于所有其他语言.
如果我理解正确的话.没有单一的字体文件(Roboto | Noto)可以支持所有语言.
有谁知道我可以用什么字体?应该默认字体(Android决定)吗?
谢谢!
我正在测试我的自定义BackupAgent.以下是我在Simulator和Eclipse ADT中的测试
使用命令测试1备份和恢复---- WORK WELL
测试2备份/卸载应用程序/重新安装应用程序----不工作
更新
有人有什么想法吗?谢谢!
我有一个OutputStream返回的实例HttpURLConnection.我需要在流中写一个UTF-8字符串.
我有两种方式:
使用OutputStream自己
// write String
os.write("some utf8 text".getBytes(Charsets.UTF_8));
Run Code Online (Sandbox Code Playgroud)使用OutputStreamWriter包装器
// BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os, CharsetUtils.UTF_8));
OutputStreamWriter osw = new OutputStreamWriter(os, CharsetUtils.UTF_8);
osw.write("some utf8 text");
Run Code Online (Sandbox Code Playgroud)问:为什么要使用OutputStreamWriter在OutputStream写字符串?
谢谢!
我正在编写一个函数来使用 SecretKeyFactory 基于密码生成密钥(字节)。我想在不再需要 SecretKey 实例时销毁它,但它会引发异常。
try {
byte[] salt = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 };
SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256");
PBEKeySpec keySpec = new PBEKeySpec("password".toCharArray(), salt, 1000, 256);
SecretKey secretkey = factory.generateSecret(keySpec);
byte[] key = secretkey.getEncoded();
// Using key
// Destroy key
Arrays.fill(key, (byte)0);
// Destroy secretKey
secretkey.destroy(); // --> Throw DestroyFailedException
} catch (Exception e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
我在 Mac 上使用 Oracle JDK1.8.0_66。
我查看了 SecretKey 源代码,发现了这个默认实现(SecretKey 实现了 Destroyable 接口)
public default void destroy() …Run Code Online (Sandbox Code Playgroud) 我正在编写一个代码来添加当前日期的天数.我有2个解决方案:
解决方案1
Date current = new Date();
// Add 100 days
Date d = new Date ( current.getTime() + 100 * 24 * 60 * 60 * 1000 );
System.out.println(d);
Run Code Online (Sandbox Code Playgroud)
解决方案2
Date current = new Date();
GregorianCalendar c = new GregorianCalendar();
c.setTime(current);
c.add(Calendar.DATE, 100);
System.out.println(c.getTime());
Run Code Online (Sandbox Code Playgroud)
结果
SOLUTION 1: Sat Apr 05 14:56:33 CDT 2014
SOLUTION 2: Sat Apr 05 13:56:33 CDT 2014
Run Code Online (Sandbox Code Playgroud)
solution_2的结果比solution_11小时的结果少.
有人有什么想法吗?谢谢!
我有一个简单的问题。我用谷歌搜索但没有找到答案。
我有一个页面。我想禁用页面内容的缓存。
是的。我可以添加缓存控制指令,例如
Cache-Control: no-cache, no-store, must-revalidate, max-age: 0
Run Code Online (Sandbox Code Playgroud)
但问题是:如果没有与返回的缓存相关的 HTTP 标头,例如 Cache-Control、Expires、Pragma、Last-Modified,...在这种情况下浏览器/代理是否会缓存响应?如果是,什么时候?
谢谢你!
我正在编写一个 ASP.NET Core 资源过滤器,我想禁用 OnResourceExecuting 方法中某些控制器/操作的处理。
我在Microsoft.AspNetCore.Mvc.Filters.ResourceExecutingContext类中找不到任何 api 来获取控制器名称和操作名称。
有人有什么想法吗?谢谢!
我正在为多种语言处理HTTP标题"Content-Language".我有两种方式:
WAY1:
// setHeader
response.setHeader("Content-Language", "en, fr"); // Using ',' as seperator
Run Code Online (Sandbox Code Playgroud)WAY2:
// addHeader ----- Not setHeader
response.addHeader("Content-Language", "en");
response.addHeader("Content-Language", "fr");
Run Code Online (Sandbox Code Playgroud)我的问题是:这两种方式是否相同?如果不是.哪一个是正确的?
谢谢!
我正在研究ASP.NET Core 2 Web应用程序。我正在处理[授权(角色或策略)]页面的“ 访问被拒绝”页面。
默认情况下,ASP.NET Core 2.0 不会显示原始URL并返回403状态,而是将请求重定向到状态为302- >这不是我想要的AccessDenied页面。
而不是重定向AccessDenied页面。我希望ASP.NET Core抛出自定义的ForbiddenException异常,以便像处理未处理的异常一样处理未经授权的访问。
这是我的身份验证配置:
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; // Cookies
options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; // Cookies
options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme; // Cookies
})
.AddCookie(options => {
options.LoginPath = "/Auth/Login/";
options.LogoutPath = "/Auth/Logout/";
// I want disable this and throw ForbiddenException instead.
options.AccessDeniedPath = "/Auth/AccessDenied/";
});
Run Code Online (Sandbox Code Playgroud)
有人有帮助吗?谢谢!
c# authorize-attribute asp.net-authorization asp.net-core asp.net-core-2.0
java ×4
android ×3
asp.net-core ×2
c# ×2
autofocus ×1
backup ×1
backup-agent ×1
calendar ×1
date ×1
datetime ×1
focus ×1
fonts ×1
http ×1
http-headers ×1
httpresponse ×1
io ×1
java-8 ×1
onfocus ×1
outputstream ×1
servlets ×1
text ×1
textview ×1
utf-8 ×1