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)
如何在组之间添加分隔符,分隔符或空格(如图片所示)?
当我调用没有头的服务器时,它的工作和服务器返回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) 哪些浏览器支持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) 我使用AndEngine-GLES2-AnchorCenter,我希望实现Google Play游戏服务.
我在同一个软件包中复制BaseGameActivity
并GameHelper
从BaseGameUtils
(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) 我正在使用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?
我想计算属于标签的帖子数量.我应该使用方法还是动态属性?
<?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)