小编Som*_*ody的帖子

IllegalStateException:链接没有NavController集

我正在使用Android导航组件进行导航.我有一个LoginFragment,它有一个按钮可以转换到SignUpFragment.单击按钮我收到此错误.

java.lang.IllegalStateException: View android.support.v7.widget.AppCompatButton{49d9bd1 VFED..C.. ...P.... 201,917-782,1061 #7f090172 app:id/signUpLink} does not have a NavController set
Run Code Online (Sandbox Code Playgroud)

这是我的nav_graph.xml

<navigation xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        app:startDestination="@id/loginFragment">
        <fragment
            android:id="@+id/loginFragment"
            android:name="org.fossasia.openevent.app.core.auth.login.LoginFragment"
            android:label="login_fragment"
            tools:layout="@layout/login_fragment">
            <action
                android:id="@+id/action_loginFragment_to_signUpFragment"
                app:destination="@id/signUpFragment" />

        </fragment>
    </navigation>
Run Code Online (Sandbox Code Playgroud)

以下是LoginFragment for Navigation中的代码 -

binding.signUpLink.setOnClickListener(Navigation.createNavigateOnClickListener(R.id.action_loginFragment_to_signUpFragment, null));
Run Code Online (Sandbox Code Playgroud)

以下是NavHostFragment的活动布局文件的摘录 -

<FrameLayout
            android:id="@+id/fragment_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            android:name="android.navigation.fragment.NavHostFragment"
            app:navGraph="@navigation/main_navigation"
            app:defaultNavHost="true"/>
Run Code Online (Sandbox Code Playgroud)

android android-architecture-components android-architecture-navigation

15
推荐指数
11
解决办法
1万
查看次数

牛顿的方法程序(在C中)循环无限运行

C中的这段代码(附在帖子中)使用Newton-Raphson方法在特定区间中找到多项式的根.

对于某些多项式,这段代码可以完美地x^3 + x^2 + x + 1运行,但运算符对于某些多项式来说是无限的x^3 - 6*x^2 + 11*x - 6.也就是说,此代码适用于输入间隔中具有一个或零根的多项式,但如果存在多个根,则它将无限期运行.

如果有人找到解决方案,请告诉我.我在代码中写了一些评论来引导读者,但如果有人发现很难理解,可以在评论中提问,我会解释一下.

#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<ctype.h>

int check(float num)                          //just a function to check for  the correct input
{
    char c;
    scanf("%c",&c);

    if(isalpha((int)c))
        printf("you entered an alphabet\n");

    else
        printf("you entered a character, please retry\n");

    return 0;
}

float func(float *p,int order,double x)                     //calculates the value of the function required in the formmula in main
{
    double fc=0.0;
    int i;

    for(i=0;i<=order;i++)
    { …
Run Code Online (Sandbox Code Playgroud)

c algorithm loops newtons-method

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

TypeError:'dict'对象在使用dict()时不可调用

我在linux2上使用Python 2.7.12(默认,2016年11月19日,06:48:10)[GCC 5.4.0 20160609],当我运行下面的代码时,显示相应的错误.我搜索了很多关于这个但我无法找到原因

>>> bob=dict(name='bob smith',age=42,pay='10000',job='dev')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'dict' object is not callable
Run Code Online (Sandbox Code Playgroud)

python

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

<枚举对象0x7f0211ea2360>

我在Python3.5.2中运行了以下代码并获得了相应的输出

>>> example = ['a','b','c','d','e']
>>> enumerate(example)
<enumerate object at 0x7f0211ea2360>
Run Code Online (Sandbox Code Playgroud)

我无法理解这个输出是什么意思.为什么输出不是这样的

 (0, 'a'), (1, 'b'), (2, 'c'), (3, 'd'), (4, 'e') 
Run Code Online (Sandbox Code Playgroud)

当我使用列表来包含这些元组时,输出是令人满意的

>>> list(enumerate(example))
[(0, 'a'), (1, 'b'), (2, 'c'), (3, 'd'), (4, 'e')]
Run Code Online (Sandbox Code Playgroud)

注意:我是python的新手,当我发布这个问题我不知道地图功能所以我没有提到这个问题 为什么地图返回地图对象而不是Python 3中的列表?

python enumerate

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

在折叠器布局中滚动时折叠的工具栏不折叠

我在“ Cordinator布局”中使用了“折叠工具栏”,但“折叠”栏仍然不会折叠,并且仍在滚动中。

这是activity_demo.xml-

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.design.widget.CoordinatorLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.design.widget.AppBarLayout
            android:id="@+id/appbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            android:fitsSystemWindows="true">

<!-- Fit the system windows for your CollapsingToolbarLayout
           also set your height to wrap_content and give image a height-->

<android.support.design.widget.CollapsingToolbarLayout
                android:id="@+id/collapsing_toolbar"
                android:fitsSystemWindows="true"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:contentScrim="?attr/colorPrimary"
                app:expandedTitleMarginStart="4dp"
                app:expandedTitleMarginEnd="64dp">

                <ImageView
                    android:id="@+id/backdrop"
                    android:layout_width="match_parent"
                    android:layout_height="244dp"
                    android:scaleType="centerCrop"
                    android:fitsSystemWindows="true"
                    android:src="@drawable/cheese"
                    app:layout_collapseMode="parallax"/>
                <!-- Tell your toolbar to scroll|enterAlways -->
                <android.support.v7.widget.Toolbar
                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                    app:layout_scrollFlags="scroll|enterAlways"/>
                <!-- add layout_gravity="bottom" -->
                <android.support.design.widget.TabLayout
                    android:id="@+id/tabs"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    app:tabSelectedTextColor="?android:attr/textColorPrimaryInverse"
                    app:tabIndicatorColor="?android:attr/textColorPrimaryInverse"
                    app:tabIndicatorHeight="4dp"
                    android:layout_gravity="bottom"/>
            </android.support.design.widget.CollapsingToolbarLayout>
        </android.support.design.widget.AppBarLayout> …
Run Code Online (Sandbox Code Playgroud)

android android-collapsingtoolbarlayout android-nestedscrollview

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