小编Sha*_*dow的帖子

Android NavigationView菜单组分隔符

Android支持设计库提供NavigationView:

 <android.support.design.widget.NavigationView
    ...
    app:menu="@menu/navigation_drawer_items" />
Run Code Online (Sandbox Code Playgroud)

菜单/ navigation_drawer_items:

<menu xmlns:android="http://schemas.android.com/apk/res/android">

    <group android:checkableBehavior="single">
        <item .../>
        ...
    </group>

    <group android:checkableBehavior="single">
        <item .../>
        ...
    </group>

</menu>
Run Code Online (Sandbox Code Playgroud)

如何在组之间添加分隔符,分隔符或空格(如图片所示)?

在此输入图像描述

android navigation-drawer android-design-library

69
推荐指数
3
解决办法
5万
查看次数

Angular2标头

当我调用没有头的服务器时,它的工作和服务器返回json:

this.http.get(url)
Run Code Online (Sandbox Code Playgroud)

但是当我添加标题时:

var headers = new Headers({'x-id': '1'});
this.http.get(url, {'headers': headers})
Run Code Online (Sandbox Code Playgroud)

浏览器返回错误:

XMLHttpRequest cannot load http://domain/api/v1/. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.
Run Code Online (Sandbox Code Playgroud)

我也试过添加Origin标题 - 浏览器错误:Refused to set unsafe header "Origin"

Access-Control-Allow-Origin头-无影响


在服务器(Laravel)上我创建了中间件Cors.php:

<?php

namespace App\Http\Middleware;

use Closure;

class Cors {
    public function handle($request, Closure $next)
    {
        return $next($request)
            ->header('Access-Control-Allow-Origin', 'http://localhost:3000')
            ->header('Access-Control-Allow-Methods', 'GET, POST, …
Run Code Online (Sandbox Code Playgroud)

cors laravel angular

15
推荐指数
2
解决办法
6333
查看次数

条件catch子句 - 浏览器支持

哪些浏览器支持Conditional catch子句

在MDN上尝试...捕获您可以找到条件捕获子句作为非标准功能.

try {
    myroutine(); // may throw three exceptions
} catch (e if e instanceof TypeError) {
    // statements to handle TypeError exceptions
} catch (e if e instanceof RangeError) {
    // statements to handle RangeError exceptions
} catch (e if e instanceof EvalError) {
    // statements to handle EvalError exceptions
} catch (e) {
    // statements to handle any unspecified exceptions
    logMyErrors(e); // pass exception object to error handler …
Run Code Online (Sandbox Code Playgroud)

javascript exception

13
推荐指数
2
解决办法
2957
查看次数

AndEngine与Google Play游戏服务

我使用AndEngine-GLES2-AnchorCenter,我希望实现Google Play游戏服务.

我在同一个软件包中复制BaseGameActivityGameHelperBaseGameUtils(Google Play游戏服务的一部分 - Android示例)中分类到我的项目util.

因为AndEngine已经使用了BaseGameActivity,我将它重命名为GBaseGameActivity并将扩展类更改为BaseGameActivity(AndEngine类),所以从这里:

public abstract class BaseGameActivity extends FragmentActivity
Run Code Online (Sandbox Code Playgroud)

至:

public abstract class GBaseGameActivity extends BaseGameActivity
Run Code Online (Sandbox Code Playgroud)

然后我扩展了我的课程GBaseGameActivity(当我扩展BaseGameActivity(AndEngine类)时,它的工作......但不是GBaseGameActivity(BaseGameUtils类))

public class BaseActivity extends GBaseGameActivity
Run Code Online (Sandbox Code Playgroud)

我尝试编译我的项目,但我得到了:

...
Could not find class 'com.xxx.xxx.util.GameHelper', referenced from method com.xxx.xxx.util.GBaseGameActivity.<init>
Could not find class 'com.xxx.xxx.util.GameHelper', referenced from method com.xxx.xxx.util.GBaseGameActivity.onCreate
FATAL EXCEPTION: main
    java.lang.NoClassDefFoundError: com.xxx.xxx.util.GameHelper
    at com.xxx.xxx.util.GBaseGameActivity.<init>(GBaseGameActivity.java:63)
    at com.xxx.xxx.BaseActivity.<init>(BaseActivity.java:35)
...
Run Code Online (Sandbox Code Playgroud)

GBaseGameActivity.java:63:

63| mHelper = new GameHelper(this);
Run Code Online (Sandbox Code Playgroud)

BaseActivity.java:35:

35| public class …
Run Code Online (Sandbox Code Playgroud)

android andengine google-play-games andengine-gles-2

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

Laravel Socialite - 通过令牌获取用户详细信息

我正在使用facebook登录和laravel REST API服务器开发android应用程序.用户在移动设备上登录后,app获取发送到我服务器的令牌.在服务器上我希望通过令牌获取facebook用户详细信息.

Facebook SDK for PHP提供了以下方法:

$session = new FacebookSession('token');
$me = (new FacebookRequest($session, 'GET', '/me',))->execute()->getGraphObject(GraphUser::className());
Run Code Online (Sandbox Code Playgroud)

Laravel Socialite可以根据该令牌获取用户的Facebook详细信息吗?或者只使用Facebook SDK

facebook-graph-api laravel laravel-5

5
推荐指数
2
解决办法
6068
查看次数

与Laravel雄辩的ORM中的'方法'与'动态属性'?

我想计算属于标签的帖子数量.我应该使用方法还是动态属性?

<?php

class Tag extends Eloquent {

    public function posts()
    {
        return $this->belongsToMany('Post');
    }

    public function postsCount()
    {
        return count($this->posts);
    }

    public function getPostsCountAttribute()
    {
        return count($this->posts);
    }

}
Run Code Online (Sandbox Code Playgroud)

所以在模板中我应该使用动态属性:

{{ $tag->postCount }}
Run Code Online (Sandbox Code Playgroud)

或方法:

{{ $tag->postCount() }}
Run Code Online (Sandbox Code Playgroud)

laravel eloquent laravel-4

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