我的代码完美无缺:每次点击导航抽屉中的项目时,都会选择该项目.
当然我想用默认片段(home)启动应用程序,但导航抽屉没有选择项目.如何以编程方式选择该项目?
public class BaseApp extends AppCompatActivity {
//Defining Variables
protected String LOGTAG = "LOGDEBUG";
protected Toolbar toolbar;
protected NavigationView navigationView;
protected DrawerLayout drawerLayout;
private DateManager db = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.base_layout);
navigationView = (NavigationView) findViewById(R.id.navigation_view);
// set the home/dashboard at startup
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.frame, new DashboardFragment());
fragmentTransaction.commit();
setNavDrawer();
}
private void setNavDrawer(){
// Initializing Toolbar and setting it as the actionbar
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
//Initializing NavigationView
//Setting Navigation View Item …Run Code Online (Sandbox Code Playgroud) 大约几个小时就对这个错误感到疯狂.
错误是:
failed to find Build Tools revision 23.0.0 rc1
Run Code Online (Sandbox Code Playgroud)
但我想要全部更新(也是发布候选人!)
这是形象:谢谢.
我如何处理我的404自定义页面(以及可能的其他错误)?
我刚尝试在路由部分添加
GET /@codes /WebController->error
Run Code Online (Sandbox Code Playgroud)
我的Class WebController处理错误,而404我解决了(部分).实际上它适用于
http://mydomain.ext/itdoesntexists
Run Code Online (Sandbox Code Playgroud)
但如果我记得一个
http://mydomain.ext/sub/maybe_another_sub/and_so_on/doesnt_exist
Run Code Online (Sandbox Code Playgroud)
我的路线(当然)不起作用.
顺便说一下,在每种情况下,它都不会推动404标题(只是对事物的疯狂看法,我正在考虑谷歌寻找资源而且它没有收到"纯粹的"404).
谢谢
我试用几天来设置和使用Propel now 2.0.PHP版本是5.4.4-14 + deb7u5
我做了什么:
0)新鲜的LAMP,在/ var/www中有一个文件夹"test"
1)Composer.json
{
"require": {
"propel/propel": "2.0.*@dev"
}
}
Run Code Online (Sandbox Code Playgroud)
(也尝试使用主页中指示的alpha,没有成功,下载但我无法使用)
2)下载所有必要的文件.
3)我可以启动"vendor/bin/propel"并在一些绿色文本后退出.
4)我使用http://propelorm.org/documentation/02-buildtime.html中指示的外键创建schema.xml
5)我设置了buildtime.cconfiguration
6)我可以创建sql:build和模型:build(我在generated-sql中找到bookstore.sql,在generated-classes中找到类)
7)我无法插入sql.我启动sql:insert,屏幕没有错误,但没有插入数据库(连接/密码没问题,双重检查).
8)我在数据库中加载自己的SQL.
9)我创建了一个index.php:
<?php
// setup the autoloading
require_once 'vendor/autoload.php';
use Propel\Runtime\Propel;
use Propel\Runtime\Connection\ConnectionManagerSingle;
$serviceContainer = Propel::getServiceContainer();
$serviceContainer->setAdapterClass('bookstore', 'mysql');
$manager = new ConnectionManagerSingle();
$manager->setConfiguration(array (
'dsn' => 'mysql:host=localhost;dbname=my_db_name',
'user' => 'my_db_user',
'password' => 's3cr3t',
));
$serviceContainer->setConnectionManager('bookstore', $manager);
echo 'All ok, for now...';
$author = new Author();
$author->setFirstName('Jane');
$author->setLastName('Austen');
$author->save();
/* …Run Code Online (Sandbox Code Playgroud) 这是我的应用程序的beahviour(1当然是正确的):

当然我只想检查一件物品.
我将这些项目分成两组(添加分隔符,请参阅我之前的问题:如何在navdrawer中添加水平分隔符?)
这是nav_menu.xml:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single"
android:id="@+id/group1" >
<item
android:id="@+id/home"
android:checked="false"
android:icon="@drawable/ic_home_black_24dp"
android:title="@string/list_home" />
<item
android:id="@+id/list_event"
android:checked="false"
android:icon="@drawable/ic_list_black_24dp"
android:title="@string/list_event" />
</group>
<group
android:checkableBehavior="single"
android:id="@+id/group2" >
<item
android:id="@+id/settings"
android:checked="false"
android:icon="@drawable/ic_settings_black_24dp"
android:title="@string/settings" />
</group>
</menu>
Run Code Online (Sandbox Code Playgroud)
这是管理NavDrawer的BaseApp:
package com.xx.views;
import android.support.design.widget.NavigationView;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.support.v7.app.ActionBarDrawerToggle;
import android.os.Bundle;
import android.view.View;
import com.xx.R;
import com.xx.mappers.DateManager;
public class BaseApp extends AppCompatActivity {
//Defining Variables
protected String LOGTAG …Run Code Online (Sandbox Code Playgroud) 我需要停止nuxt-link转到另一页。
这是我的代码
<nuxt-link :to="item.url" data-toggle="collapse" class="nav-link" v-b-toggle="'collapse-'+index" :ref="'parent-'+index" @click.native="toggleSubMenuIcon(index)">
methods: {
toggleSubMenuIcon(index) {
this.$store.dispatch('layout/TOGGLE_SUBMENU_ICON', index)
}
}
Run Code Online (Sandbox Code Playgroud)
我需要一个类似的 e.preventDefault() 来阻止浏览器访问 item.url 上的页面
我也试过
<nuxt-link :to="item.url" data-toggle="collapse" class="nav-link" v-b-toggle="'collapse-'+index" :ref="'parent-'+index" @click.native="toggleSubMenuIcon(index), event => event.preventDefault()">
Run Code Online (Sandbox Code Playgroud)
没有成功。
我不会在 url 中使用简单的“哈希”,因为我不喜欢它打印在 URL 浏览器中。
谢谢
Guzzle / Http的新手。
我有一个API rest url登录名,如果未授权,则使用401代码回答;如果缺少值,则使用400回答。
我将获得http状态代码以检查是否存在某些问题,但不能仅包含代码(整数或字符串)。
这是我的代码,我确实在这里使用了说明(http://docs.guzzlephp.org/en/stable/quickstart.html#exceptions)
namespace controllers;
use GuzzleHttp\Psr7;
use GuzzleHttp\Exception\ClientException;
$client = new \GuzzleHttp\Client();
$url = $this->getBaseDomain().'/api/v1/login';
try {
$res = $client->request('POST', $url, [
'form_params' => [
'username' => 'abc',
'password' => '123'
]
]);
} catch (ClientException $e) {
//echo Psr7\str($e->getRequest());
echo Psr7\str($e->getResponse());
}
Run Code Online (Sandbox Code Playgroud) 我在控制台中出现此错误:
Highcharts warning: Consider including the "accessibility.js" module to make your chart more usable for people with disabilities. Set the "accessibility.enabled" option to false to remove this warning. See https://www.highcharts.com/docs/accessibility/accessibility-module.
Run Code Online (Sandbox Code Playgroud)
在文档中找不到Set the "accessibility.enabled" option to false.
这是我传递给组件的选项:
const optionNUsersPerService = {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title: {
text: 'Utenti per servizio'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
accessibility: {
point: {
valueSuffix: '%'
}
},
plotOptions: {
pie: {
allowPointSelect: …Run Code Online (Sandbox Code Playgroud) 我正在通过 Guzzle 调用 API。
public function request(string $method, string $uri, array $data = [], array $headers = [])
{
$response = $this->getClient()->$method($uri, [
'headers' => $headers,
'query' => $data,
]);
echo "1";
var_dump($response->getBody()->getContents());
$this->checkError($response);
echo "2";
var_dump($response->getBody()->getContents());
return $response;
}
public function checkError($response)
{
$json = json_decode($response->getBody()->getContents());
echo "3";
var_dump($json);
}
Run Code Online (Sandbox Code Playgroud)
我的 json 测试(从“1”输出)是
{
"args":{
},
"headers":{
"Authorization":"Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
"Host":"httpbin.org",
"User-Agent":"GuzzleHttp/6.3.3 curl/7.59.0 PHP/7.2.4"
},
"origin":"1.2.3.4, 1.2.3.4",
"url":"https://httpbin.org/get"
}
Run Code Online (Sandbox Code Playgroud)
但是,在代码“2”中,我有一个空字符串,而在代码“3”(“checkError”方法的输出)中,我有一个空字符串。
如果我注释掉 checkError 方法,我希望在片段 2 中再次使用相同的 json,但我有一个空字符串。为什么会有这种行为?
我需要验证自己的领域; 合法只是数字.
这是简单的HTML:
<div class="form-group">
<label for="superficie">Superficie</label>
<input type="text" class="form-control required-field" data-type="number" name="superficie" />
</div>
Run Code Online (Sandbox Code Playgroud)
这就是Jquery:
$('.current .required-field').each(function(index) {
$(this).keyup(function() {
var input_type = $(this).data('type');
validate($(this), input_type);
});
});
function validate(input, input_type) {
switch(input_type) {
case 'number':
if (input.value != input.value.replace(/[^0-9\.]/g, '')) {
input.value = input.value.replace(/[^0-9\.]/g, '');
}
break;
}
}
Run Code Online (Sandbox Code Playgroud)
控制台返回错误:
input.value未定义.