小编Jon*_*han的帖子

为什么Android BottomNavigationView没有出现?

我正在使用新的Android BottomNavigationView但底部导航MenuItem操作视图未显示.

调试后,我发现菜单项不为null,可见性可见.

在检查根视图的高度和宽度之后,即使在对布局layout_width=50dplayout_height=50dp根元素中的值进行硬编码之后它也会变为0 .

这是我的底部导航菜单:

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

<item
    android:id="@+id/nearby_fragment"
    android:enabled="true"
    android:icon="@drawable/homenearbyfragment"
    android:title="@string/bottom_nearby"
    app:showAsAction="always"/>

<item
    android:id="@+id/route_fragment"
    android:title="@string/bottom_homescreen"
    android:enabled="true"
    app:showAsAction="always"
    android:icon="@drawable/home_mycommute" />

<item
    android:id="@+id/newsfeed_activity"
    android:title="@string/bottom_news"
    android:enabled="true"
    app:showAsAction="always"
    android:icon="@drawable/newsfeed"
    app:actionLayout="@layout/bagde_layout"/>

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

我的动作布局:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="?android:attr/actionButtonStyle"
android:layout_width="50dp"
android:layout_height="50dp"
android:clickable="true"
android:focusable="true"
android:gravity="center">

<ImageView
    android:id="@+id/menu_badge_icon"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/newsfeed" />

<TextView
    android:id="@+id/menu_badge"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="top|end"
    android:layout_marginTop="4dp"
    android:background="@drawable/circle_bg"
    android:gravity="center"
    android:textColor="@android:color/white"
    android:textSize="8sp"
    />
Run Code Online (Sandbox Code Playgroud)

在我Activity我试图设置:

private void setCountOnNews(Menu menu) {
    mReportMenu = menu.findItem(R.id.newsfeed_activity);
    FrameLayout count = (FrameLayout) mReportMenu.getActionView();
    count.setOnClickListener(new …
Run Code Online (Sandbox Code Playgroud)

android bottomnavigationview

13
推荐指数
1
解决办法
1585
查看次数

React Native启动项目捆绑失败,出现Unexpected Token错误

我正在尝试使用https://facebook.github.io/react-native/docs/getting-started.html上的说明为Android创建我的第一个React Native应用程序.设置依赖项并连接我的Android设备后,我跑了

react-native init app
cd app
react-native run-android
Run Code Online (Sandbox Code Playgroud)

这启动了React Packager,它无法捆绑此错误:

错误:捆绑失败:"TransformError:/Users/luky/dev/app/index.android.js:意外令牌"(处理预设时:\"/ Users/luky/dev/app/node_modules/babel-preset-react-本地/ index.js\")"

我在用:

  • OSX El Capitan 10.11.6.
  • 节点版本6.9.2
  • react-native version 0.47.1.

我将生成的项目(包括node_modules)推送到Github,以防它有所帮助:https://github.com/luky1971/react-native-app

有谁知道为什么我可能会收到意外的令牌错误?任何帮助将不胜感激!

babel node.js react-native

12
推荐指数
2
解决办法
6524
查看次数

只对正值进行排序,并使用它的索引保持负值,因为它是一个数组

我需要按升序对数组进行排序,仅用于正值.对于负值,指数位置将保持不变.

如果数组是:int[] inputArray = {-1, 150, 190, 170, -1, -1, 160, 180}.

输出应该是这样的 - int[] outputArray = {-1, 150, 160, 170, -1, -1, 180, 190}.

但就我而言,输出就是这个 - int[] outputArray = {-1, 150, 170, 190, -1, -1, 160, 180}.

这是我的代码如下:

public static void main(String[] args) {
    int[] inputArray = {-1, 150, 190, 170, -1, -1, 160, 180};
    int[] outputArray = sortByHeight(inputArray);

    for (int item : outputArray) {
        System.out.print(item + ", ");
    }
}

public static int[] sortByHeight(int[] …
Run Code Online (Sandbox Code Playgroud)

java arrays sorting

8
推荐指数
3
解决办法
1054
查看次数

ROS安装错误(Ubuntu 16.04中的ROS动力学)

中列出的步骤顺序http://wiki.ros.org/kinetic/Installat...已被跟踪.(尝试在Ubuntu 16.04中安装ROS kinetic)输入以下命令时出错:

$sudo apt-get install ros-kinetic-desktop-full
Run Code Online (Sandbox Code Playgroud)

某些软件包无法安装.这可能意味着您已经请求了一个不可能的情况,或者如果您正在使用不稳定的分发,某些必需的包尚未创建或已被移出Incoming.以下信息可能有助于解决此问题:

以下软件包具有未满足的依赖性:ros-kinetic-desktop-full:取决于:ros-kinetic-desktop但它不会被安装取决于:ros-kinetic-perception但它不会被安装取决于:ros-kinetic - 模拟器,但它不会安装取决于:ros-kinetic-urdf-tutorial但它不会被安装E:无法纠正问题,你已经破坏了包.

ros ubuntu-16.04

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

对pthread CLion的未定义引用

我正在尝试在CLion中运行这个简单的线程c ++程序

#include <iostream>
#include <thread>

using namespace std;


//Start of the thread t1
 void hello() {
     cout << "Hello,concurrent world!" << endl; }



 int main() {
     thread t1(hello);     // spawn new thread that calls hello()

     cout << "Concurrency has started!" << endl;
     t1.join();            

     cout << "Concurrency completed!";

     return 0;
   }
Run Code Online (Sandbox Code Playgroud)

我的问题是有一个未定义的引用pthread的错误,我没有看出我做错了什么...请注意我在CLion上这样做.

c++ pthreads c++11 clion

6
推荐指数
3
解决办法
9924
查看次数

Linux 内核“保留”内存

我正在尝试为低内存系统(16MB ram)编译内核(3.14,arm64 arch)。我设法关闭了我不需要的所有功能,基本上没有设备,没有 fs,没有模块,没有 ZONE_DMA,一个非常非常基本的内核。

但是,当我启动内核时,我看到:

内存:860K/16384K可用(789K内核代码、67K rwdata、56K Rodata、64K init、38K bss、15524K保留)

  • 这个保留的内存是什么?

  • 我怎样才能减少这种情况?储备占用了我的大量内存,只剩下 860K 可用

提前致谢!

linux memory optimization kernel arm64

5
推荐指数
1
解决办法
7386
查看次数

Yii2 + Codeception:如何使用fixtures?

我使用 Codeception 为 Yii2 应用程序编写了一个简单的测试。而不是使用真正的 MySQL 数据库,我想使用装置。

这是代码:

测试/PersonTest.php

namespace app\tests\unit\models;

use tests\fixtures;
use app\controllers;

class PersonTest extends \Codeception\Test\Unit
{
    protected $tester;
    public $appConfig = '@app/config/main.php';

    protected function _before(){ }
    protected function _after(){ }

    public function _fixtures()
    {
        return [ 'Person' => fixtures\PersonFixture::className() ];
    }

    public function testUser(){
        $person = Person::findOne( [ "id" => 1 ] );
        $userId = isset( $person->id ) ? $person->id : false;
        $this->assertEquals( 1, $userId );
    }
}
Run Code Online (Sandbox Code Playgroud)

测试/夹具/数据/Person.php

return [
    'person1' => [
        'id' …
Run Code Online (Sandbox Code Playgroud)

unit-testing fixtures yii yii2 codeception

5
推荐指数
1
解决办法
4995
查看次数

如何在约束布局中应用分隔线或视图

我想在约束布局中的某些位置应用分隔线,但是当我通过简单视图进行操作时,整个布局将移至顶部,并且所有内容都将合并。我只想在整个设计中使用约束布局。

<TextView
    android:id="@+id/textView16"
    android:layout_width="0dp"
    android:layout_height="18dp"
    android:text="TextView"
    app:layout_constraintLeft_toRightOf="@+id/imageView11"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="8dp"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintHorizontal_bias="1.0"
    android:layout_marginTop="13dp"
    app:layout_constraintTop_toBottomOf="@+id/textView14"
    app:layout_constraintBottom_toBottomOf="parent"
    android:layout_marginBottom="8dp"
    app:layout_constraintVertical_bias="0.0"
    android:layout_marginStart="8dp"
    android:layout_marginEnd="8dp" />

<TextView
    android:id="@+id/textView20"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:text="TextView"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    android:layout_marginTop="8dp"
    app:layout_constraintTop_toBottomOf="@+id/textView16"
    app:layout_constraintLeft_toRightOf="@+id/imageView11"
    android:layout_marginLeft="8dp"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintVertical_bias="0.0"
    android:layout_marginRight="8dp"
    android:layout_marginStart="8dp"
    android:layout_marginEnd="8dp" />

<View
    android:layout_width="0dp"
    android:layout_height="2dp"
    android:background="@android:color/background_dark"
    tools:layout_editor_absoluteY="98dp"
    android:id="@+id/view"
    tools:layout_editor_absoluteX="0dp" />

<TextView
    android:id="@+id/textView21"
    android:layout_width="wrap_content"
    android:layout_height="17dp"
    android:layout_marginBottom="8dp"
    android:layout_marginRight="8dp"
    android:text="Nivedita Parmar"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintHorizontal_bias="0.025"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/view"
    app:layout_constraintVertical_bias="0.035"
    android:layout_marginEnd="8dp" />
Run Code Online (Sandbox Code Playgroud)

请给一些想法。提前致谢..

android constraints android-constraintlayout

5
推荐指数
1
解决办法
3635
查看次数

如何在下一次按钮点击之前等待slideToggle结束

 $('.mybutton').click(function(){
 $('.someclasstohide').slideToggle(500)
 })
Run Code Online (Sandbox Code Playgroud)

如何使我的按钮等到幻灯片完成?我的意思是在下一次点击之前等 如果我添加insert.stop(),它只是停止垃圾邮件,直到slideToggle完成.

javascript jquery

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