小编Luc*_*cky的帖子

如何计算Android中的通知数量和显示单个图标?

我有多个Android通知,但是当我从我的Web服务器发送消息时,android设备会在状态栏上创建一个新的通知图标.我想计算未读通知的数量,statusbar用单个图标显示它,当读取通知时,通知必须更改未读通知计数.我该怎么做?在这张图片中看起来像"3 Others":通知图标

eclipse android android-notifications android-notification-bar

10
推荐指数
1
解决办法
3万
查看次数

使用javascript上传图片

我正试图Object在客户端获取javascript 图像以使用jQuery发送它

<html>
<body>
<script language="JavaScript">
function checkSize()
{
    im = new Image();
    im.src = document.Upload.submitfile.value;
if(!im.src)
    im.src = document.getElementById('submitfile').value;
    alert(im.src);
    alert(im.width);
    alert(im.height);
    alert(im.fileSize);

}
</script>
<form name="Upload" action="#" enctype="multipart/form-data" method="post">
   <p>Filename: <input type="file" name="submitfile" id="submitfile" />
   <input type="button" value="Send" onClick="checkSize();" />
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

但是在这个代码仅alert(im.src)是显示src文件,但alert(im.width),alert(im.height),alert(im.filesize)不能正常工作和报警0,0,undefined分别.请告诉我如何使用javascript访问图像对象?

javascript

10
推荐指数
1
解决办法
6万
查看次数

动画:悬停:之后

我有以下css规则:

button:hover:after {
    content: ' ' attr(title);
}
Run Code Online (Sandbox Code Playgroud)

基本上该按钮具有作为内容和标题属性的fontawesome图标.当您将鼠标悬停在按钮上时,它会添加一个空格,然后将标题添加到按钮的内容中.看到这个JSFiddle

现在问题是,我将如何设置动画?我希望按钮的新宽度是动画的,所以它不会显示为静态和丑陋.

html css pseudo-element css-transitions css-animations

10
推荐指数
1
解决办法
1878
查看次数

无法修改iframe的内容,有什么不对?

我试图修改iframe的内容,但它不起作用.

这是我的main.html

<html>
<head><title>Main page</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
</head>
<body>

<h3>Main page</h3>
<iframe src="ifr.htm" id="ifr" name="ifr"></iframe>
</body>

<script>
$(document).ready(function(){
    $('#ifr').load(function(){
        $('#ifr').contents().find('body').html('Hey, i`ve changed content of <body>!    Yay!!!');
    });
});

</script>
</html>
Run Code Online (Sandbox Code Playgroud)

这是我的ifr.htm

<html>
<head><title>Iframe page</title></head>
<body>
 Content to be displayed in iframe ...
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

html jquery

9
推荐指数
1
解决办法
3万
查看次数

用于唯一ID的Java中的序列生成器

我打算编写一个序列生成器,它将在post期间用于我的REST资源实现类,以生成唯一的id.由于每个post请求都由单独的线程处理,我使变量volatile和方法同步.我没有选择使用序列或传统RDBMS提供的东西.

public class SequenceGen {
    volatile static int n = 0;  
    public synchronized int nextNum(){
        return n++;
    }   
}
Run Code Online (Sandbox Code Playgroud)

这是我到目前为止,并计划在我的REST实现中创建SequenceGen的变量.我的实际问题是它会在某个地方破裂吗?我测试了两个线程,我没有看到重复的任何值.

java multithreading sequence

9
推荐指数
1
解决办法
3万
查看次数

"无法在Ant中创建任务或输入antlib:org.apache.maven.artifact.ant:mvn"错误

在运行ant任务时,Ant构建无法运行build.xml.我在控制台中收到以下错误:

Buildfile: F:\Eclipse Projects\my_project\build.xml
  [typedef] Could not load definitions from resource org/apache/maven/artifact/ant/antlib.xml. It could not be found.

BUILD FAILED
F:\my_project\build.xml:32: Problem: failed to create task or type antlib:org.apache.maven.artifact.ant:mvn
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
No types or tasks have been defined in this namespace yet

This appears to be an antlib declaration. 
Action: Check that the implementing …
Run Code Online (Sandbox Code Playgroud)

java eclipse ant maven

9
推荐指数
2
解决办法
1万
查看次数

使用HttpUrlConnection Android将base64编码图像发送到服务器

我正在尝试使用HttpUrlConnection将base64编码的图像发送到服务器.我遇到的问题是大多数图像都成功发送,但有些图像会生成FileNotFound异常.我可以在下面找到编码图像的代码.

public static String encodeImage(Bitmap thumbnail) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            thumbnail.compress(Bitmap.CompressFormat.JPEG, 100, baos);
            byte[] b = baos.toByteArray();
            String imageEncoded = Base64.encodeToString(b,Base64.URL_SAFE);
            return imageEncoded;
        }
Run Code Online (Sandbox Code Playgroud)

当我改变这条线时:

String imageEncoded = Base64.encodeToString(b,Base64.URL_SAFE);
Run Code Online (Sandbox Code Playgroud)

至:

String imageEncoded = Base64.encodeToString(b,Base64.DEFAULT);
Run Code Online (Sandbox Code Playgroud)

然后大多数图像生成FileNotFoundException,一些成功发送到服务器.

下面是我的HttpUrlConnection的代码:

public class HttpManager {

    public static String getData(RequestPackage p) {

        BufferedReader reader = null;
        String uri = p.getUri();
        if (p.getMethod().equals("GET")) {
            uri += "?" + p.getEncodedParams();
        }

        try {
            URL url = new URL(uri);
            HttpURLConnection con = (HttpURLConnection) url.openConnection();
            con.setRequestMethod(p.getMethod());


            if (p.getMethod().equals("POST")) …
Run Code Online (Sandbox Code Playgroud)

java base64 android image httpurlconnection

8
推荐指数
1
解决办法
1万
查看次数

Mybatis XML与注释

我已经阅读了关于Mybatis的书和文档,XML和Annotation都做了我想要的,但是从myBatis官方网站,他们声称XML是一种更好的做Mappers的方法,因为Java注释有局限性.

我个人更喜欢注释,例如

public interface PersonDAO {

    String INSERT_PERSON = "insert into person (title,firstName,surName,jobTitle,dob,email,mobile,landPhone,fax,twitter,facebook,linkedin) VALUES  (#{title},#{firstName},#{surName},#{jobTitle},#{dob},#{email},#{mobile},#{landPhone},#{fax},#{twitter},#{facebook},#{linkedin})";
    String UPDATE_PERSON = "update person set title=#{title},firstName=#{firstName},surName=#{surName},jobTitle=#{jobTitle},dob=#{dob},email=#{email},mobile=#{mobile},landPhone=#{landPhone},fax=#{fax},twitter=#{twitter},facebook=#{facebook},linkedin=#{linkedin} where id=#{id}";
    String GET_PERSON_BY_ID = "SELECT * FROM vw_person WHERE id = #{personId}";
    String DELETE_PERSON = "DELETE FROM person WHERE id = #{personId}";

    @Select(GET_PERSON_BY_ID)
    public PersonVO doSelectPerson(long personId) throws Exception;

    @Update(UPDATE_PERSON)@Options(flushCache = true, useCache = true)
    public int doUpdatePerson(PersonVO vo) throws Exception;


    @Insert(INSERT_PERSON)@Options(useGeneratedKeys = true, keyProperty = "id", flushCache = true)
    public int doCreatePerson(PersonVO person) throws Exception;

    @Delete(DELETE_PERSON)@Options(flushCache …
Run Code Online (Sandbox Code Playgroud)

java ibatis mybatis

8
推荐指数
1
解决办法
1万
查看次数

如何在重新启动时禁用换行?

<div ui-grid="gridOptions" class="grid" ui-grid-resize-columns="" ui-grid-pinning=""
                     ui-grid-pagination="" ui-grid-selection=""></div>
Run Code Online (Sandbox Code Playgroud)

当我重新启动时,我不希望断行,我想将此代码保留在一行上.

我正在使用webstorm 11.如何做到这一点?

jetbrains-ide phpstorm webstorm

8
推荐指数
1
解决办法
4204
查看次数

如何根据百里香的条件将风格应用于div?

我有一个<div>块需要设置display:nonedisplay:block基于条件.html看起来像这样,

<div style="display:none;"> 
    //some html block content
</div>
Run Code Online (Sandbox Code Playgroud)

我在百里香试过了以下代码,

<div th:style="${condition} == 'MATCH' ? display:block : display:none"> 
    //some html block content
</div>
Run Code Online (Sandbox Code Playgroud)

但上面的表达不起作用.抛出org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression:错误信息.

我可以th:classappend设置一些课程并完成这项工作,但想知道elvis/ternary操作员是否会支持thymeleaf th:style标签.

conditional-operator thymeleaf

8
推荐指数
1
解决办法
2万
查看次数