小编Din*_*ino的帖子

创建持久性通知并阻止状态栏中的通知

我有以下代码,我用于Android应用程序:

package com.authorwjf.e_notifications;

import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;

public class Main extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Bitmap bm = Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.avatar), 
                getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_width),
                getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_height), 
                true);
        Intent intent = new Intent(this, Main.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 01, intent, Intent.FLAG_ACTIVITY_CLEAR_TASK);
        Notification.Builder builder = new Notification.Builder(getApplicationContext());
        builder.setContentTitle("This is the title");
        builder.setContentText("This is the text");
        builder.setSubText("Some sub text");
        builder.setNumber(101);
        builder.setContentIntent(pendingIntent);
        builder.setTicker("Fancy Notification");
        builder.setSmallIcon(R.drawable.ic_launcher);
        builder.setLargeIcon(bm);
        builder.setAutoCancel(true);
        builder.setPriority(0); …
Run Code Online (Sandbox Code Playgroud)

notifications android

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

使用css垂直居中按钮

我试图在表格单元格中进行一个简单的输入按钮居中对齐.

我的标记是:

<table width="500" border="1">
  <tr>
    <td width="390">XXXXXXXXX</td>
    <td width="110" rowspan="2" valign="middle"><input type="button" value="submit"></td>
  </tr>
  <tr>
    <td>YYYYYYYY</td>
  </tr>
</table>
<br /><br />
<div style="width:500px;">
  <div style="float:left;width:390px;">
    <div>XXXXXXX</div>
    <div>YYYYYYY</div>
  </div>
  <div style="vertical-align:middle;width:110px;float:right;">
    <div><input type="button" value="submit"></div>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

可以在这里查看:

http://jsfiddle.net/tP4sD/

我已经做了一个表格版本,显示了我想要实现的布局.请注意,由"XXXXX"或"YYYYYY"表示的文本具有可变长度.

html css layout

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

转换PHP while循环以使用PDO

我正在通过切换到PDO来更新我的应用程序.我有以下代码:

$stmt = $db->prepare("select * from `product` where productid in (:productidLst)");
$stmt->bindParam(":productidLst",$productidLst, PDO::PARAM_INT);
$stmt->execute();
Run Code Online (Sandbox Code Playgroud)

在上面的代码之后,var $ productidLst是1,2我想使用相当于此的PDO:

while($rs=mysql_fetch_assoc($res)){
    $rs['qty']=$_SESSION['basket'][$rs['productid']];
    $rs['total'] += $rs['qty']*$rs['price'];
    $total += $rs['total'];
    $a[] = $rs;
}
Run Code Online (Sandbox Code Playgroud)

我已经尝试了很多组合,但没有成功,所以任何帮助这将是赞赏(在第二个代码块$ res是sql).其次我已将参数$ productidLst设置为INT这是正确的还是应该是字符串?

-------------------- UPDATE 1 ---------------------------- ------------------------

我试过以下代码:

$stmt = $db->prepare("select * from `product` where productid in (:productidLst)");
foreach ($stmt->execute(array(':productidLst' => $productidLst)) as $row) 
{
    $total += $row['total'];
}
Run Code Online (Sandbox Code Playgroud)

返回:为foreach()错误提供的参数无效

php sql pdo

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

Laravel 5 View composer给出了一个未定义的变量错误

我正在使用Laravel 5,我正在尝试将类别变量输出到视图,但目前我收到一个未定义的变量错误.

这是代码.

首先在config/app.php中:

'App\Providers\AppServiceProvider',
Run Code Online (Sandbox Code Playgroud)

在app/Providers/AppServiceProvider.php中:

public function boot()
    {
        View::composer('partials.menu', function($view)
        {
            $view->with('categories', Category::all());
        });
    }
Run Code Online (Sandbox Code Playgroud)

在partials/menu.blade.php中:

<ul>
    <li>Home</li>
    @foreach($categories as $category)
        <li><a href="/store/category/{!! $category->id !!}">{!! $category->name !!}</a></li>
    @endforeach
    <li>Basket</li>
    <li>Checkout</li>
    <li>Contact Us</li>
</ul>
Run Code Online (Sandbox Code Playgroud)

并在store/products.php中:

@include('partials.menu')
Run Code Online (Sandbox Code Playgroud)

我得到的确切错误是:未定义的变量:类别任何帮助解决这个将不胜感激.

谢谢

views composer-php laravel-5

6
推荐指数
2
解决办法
2029
查看次数

使用 htaccess 通过 ssl 不安全的内容图像和 js

我有以下 htaccess 文件:

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !ssl

....// lots of rewrite rules

RewriteCond %{SERVER_PORT} ^443$
RewriteCond $1 !^ssl
RewriteRule (.*) http://www.mydomain.com/$1 [R,L]
RewriteCond %{SERVER_PORT} ^80$
RewriteCond $1 ^ssl
RewriteRule (.*) https://www.mydomain.com/$1 [R,L]
Run Code Online (Sandbox Code Playgroud)

基本上,当我加载安全页面时,我会加载很多不安全的图像和 js,我该如何修改我的 htacccess 以安全加载此内容。

请注意,图像和 js 的文件夹是

/js 
/images
Run Code Online (Sandbox Code Playgroud)

并且安全内容是从 /ssl 提供的

谢谢

php security .htaccess ssl

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

搜索引擎机器人如何工作?

机器人(搜索引擎的索引)如何编程以及它们如何运作?

indexing search bots web-crawler

0
推荐指数
1
解决办法
261
查看次数