问:
Why this TextViews are not showing when I run into a real device or emulator
Hello guys I have designed a GridLayout with CardViews to make a Dashboard but  the TextViews of the items are not showing in the emulator and a real device.. in the designer view it are showing but when I run it those TextView are not showing.. what could happen?
Here is my blueprint view:

And this is the UI design:

as we can see the textview if they are showing in the user interface..
Here is my code of the xml layout:

```<code>    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
    android:weightSum="10"
    android:background="@drawable/header_background2"
    tools:context=".MainActivity">

    <RelativeLayout
        android:layout_weight="1"
        android:layout_width="match_parent"
        android:layout_height="0dp">
    <TextView
        android:id="@+id/textGrid"
        android:text="GRID LAYOUT"
        android:textSize="30sp"
        android:textStyle="bold"
        android:textColor="@android:color/white"
        android:layout_centerInParent="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

    </RelativeLayout>

    <GridLayout
        android:columnCount="2"
        android:rowCount="3"
        android:alignmentMode="alignMargins"
        android:columnOrderPreserved="false"
        android:layout_weight="8"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:padding="10dp">
        <!--  Row 1 -->
            <!-- Column 1 -->
            <androidx.cardview.widget.CardView
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:layout_columnWeight="1"
                android:layout_rowWeight="1"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                app:cardCornerRadius="8dp"
                app:cardElevation="5dp">

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal|center_vertical"
                    android:layout_margin="16dp"
                    android:orientation="vertical">

                    <ImageView
                        android:id="@+id/chartDiet"
                        android:layout_width="120dp"
                        android:layout_height="120dp"
                        android:layout_gravity="center_horizontal"
                        android:src="@drawable/diet" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:text="Dieta"
                        android:textColor="@android:color/black"
                        android:textSize="18sp"
                        android:textStyle="bold" />
                </LinearLayout>

            </androidx.cardview.widget.CardView>
            <!-- Column 2 -->
            <androidx.cardview.widget.CardView
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:layout_rowWeight="1"
                android:layout_columnWeight="1"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_marginBottom="16dp"
                app:cardCornerRadius="8dp"
                app:cardElevation="5dp">

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal|center_vertical"
                    android:layout_margin="16dp"
                    android:orientation="vertical">

                    <ImageView
                        android:id="@+id/chartExercise"
                        android:layout_width="120dp"
                        android:layout_height="120dp"
                        android:layout_gravity="center_horizontal"
                        android:src="@drawable/exercise" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:text="Exercise"
                        android:textColor="@android:color/black"
                        android:textSize="18sp"
                        android:textStyle="bold" />
                </LinearLayout>

            </androidx.cardview.widget.CardView>

        <!--  Row 2 -->
            <!-- Column 1 -->
            <androidx.cardview.widget.CardView
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:layout_rowWeight="1"
                android:layout_columnWeight="1"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_marginBottom="16dp"
                app:cardCornerRadius="8dp"
                app:cardElevation="5dp">

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal|center_vertical"
                    android:layout_margin="16dp"
                    android:orientation="vertical">

                    <ImageView
                        android:id="@+id/chartMeditation"
                        android:layout_width="120dp"
                        android:layout_height="120dp"
                        android:layout_gravity="center_horizontal"
                        android:src="@drawable/meditation" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:text="Meditation"
                        android:textColor="@android:color/black"
                        android:textSize="18sp"
                        android:textStyle="bold" />
                </LinearLayout>

            </androidx.cardview.widget.CardView>
            <!-- Column 2 -->
            <androidx.cardview.widget.CardView
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:layout_rowWeight="1"
                android:layout_columnWeight="1"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_marginBottom="16dp"
                app:cardCornerRadius="8dp"
                app:cardElevation="5dp">

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal|center_vertical"
                    android:layout_margin="16dp"
                    android:orientation="vertical">

                    <ImageView
                        android:id="@+id/chartYoga"
                        android:layout_width="120dp"
                        android:layout_height="120dp"
                        android:layout_gravity="center_horizontal"
                        android:src="@drawable/yoga" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:text="Yoga"
                        android:textColor="@android:color/black"
                        android:textSize="18sp"
                        android:textStyle="bold" />
                </LinearLayout>

            </androidx.cardview.widget.CardView>

        <!--  Row 3 -->

        <!-- Column 1 -->
        <androidx.cardview.widget.CardView
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_rowWeight="1"
            android:layout_columnWeight="1"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:layout_marginBottom="16dp"
            app:cardCornerRadius="8dp"
            app:cardElevation="5dp">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal|center_vertical"
                android:layout_margin="16dp"
                android:orientation="vertical">

                <ImageView
                    android:id="@+id/chartRunning"
                    android:layout_width="120dp"
                    android:layout_height="120dp"
                    android:layout_gravity="center_horizontal"
                    android:src="@drawable/running" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="Running"
                    android:textColor="@android:color/black"
                    android:textSize="18sp"
                    android:textStyle="bold" />
            </LinearLayout>

        </androidx.cardview.widget.CardView>
        <!-- Column 2 -->
        <androidx.cardview.widget.CardView
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_rowWeight="1"
            android:layout_columnWeight="1"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:layout_marginBottom="16dp"
            app:cardCornerRadius="8dp"
            app:cardElevation="5dp">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal|center_vertical"
                android:layout_margin="16dp"
                android:orientation="vertical">

                <ImageView
                    android:id="@+id/chartWorkout"
                    android:layout_width="120dp"
                    android:layout_height="120dp"
                    android:layout_gravity="center_horizontal"
                    android:src="@drawable/workout"
                    />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="Workout"
                    android:textColor="@android:color/black"
                    android:textSize="18sp"
                    android:textStyle="bold" />
            </LinearLayout>

        </androidx.cardview.widget.CardView>

    </GridLayout>

</LinearLayout>
</code>```

Someone can help me i don't know where is the error.. or i have a bad design and maybe I should start again with another project using ConstraintLayout like root element..
thanks..
PD: the code for every row is the same only change the image and textview

答:
Is working on my emulator
my dependency in build.gradle is
    implementation 'androidx.cardview:cardview:1.0.0'
please try to change to

```<code><?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
    android:weightSum="10"
    tools:context=".MainActivity">

    <RelativeLayout
        android:layout_weight="1"
        android:layout_width="match_parent"
        android:layout_height="0dp">
        <TextView
            android:id="@+id/textGrid"
            android:text="GRID LAYOUT"
            android:textSize="30sp"
            android:textStyle="bold"
            android:textColor="@android:color/white"
            android:layout_centerInParent="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>

    </RelativeLayout>

    <GridLayout
        android:columnCount="2"
        android:rowCount="3"
        android:alignmentMode="alignMargins"
        android:columnOrderPreserved="false"
        android:layout_weight="8"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:padding="10dp">
        <!--  Row 1 -->
        <!-- Column 1 -->
        <androidx.cardview.widget.CardView
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_columnWeight="1"
            android:layout_rowWeight="1"
            android:layout_marginBottom="16dp"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            app:cardCornerRadius="8dp"
            app:cardElevation="5dp">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal|center_vertical"
                android:layout_margin="16dp"
                android:orientation="vertical">

                <ImageView
                    android:id="@+id/chartDiet"
                    android:layout_width="120dp"
                    android:layout_height="120dp"
                    android:layout_gravity="center_horizontal"
                    android:src="@drawable/ic_collections_bookmark_black_24dp" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="Dieta"
                    android:textColor="@android:color/black"
                    android:textSize="18sp"
                    android:textStyle="bold" />
            </LinearLayout>

        </androidx.cardview.widget.CardView>
        <!-- Column 2 -->
        <androidx.cardview.widget.CardView

            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_rowWeight="1"
            android:layout_columnWeight="1"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:layout_marginBottom="16dp"
            app:cardCornerRadius="8dp"
            app:cardElevation="5dp">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal|center_vertical"
                android:layout_margin="16dp"
                android:orientation="vertical">

                <ImageView
                    android:id="@+id/chartExercise"
                    android:layout_width="120dp"
                    android:layout_height="120dp"
                    android:layout_gravity="center_horizontal"
                    android:src="@drawable/ic_collections_bookmark_black_24dp" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="Exercise"
                    android:textColor="@android:color/black"
                    android:textSize="18sp"
                    android:textStyle="bold" />
            </LinearLayout>

        </androidx.cardview.widget.CardView>

        <!--  Row 2 -->
        <!-- Column 1 -->
        <androidx.cardview.widget.CardView

            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_rowWeight="1"
            android:layout_columnWeight="1"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:layout_marginBottom="16dp"
            app:cardCornerRadius="8dp"
            app:cardElevation="5dp">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal|center_vertical"
                android:layout_margin="16dp"
                android:orientation="vertical">

                <ImageView
                    android:id="@+id/chartMeditation"
                    android:layout_width="120dp"
                    android:layout_height="120dp"
                    android:layout_gravity="center_horizontal"
                    android:src="@drawable/ic_collections_bookmark_black_24dp" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="Meditation"
                    android:textColor="@android:color/black"
                    android:textSize="18sp"
                    android:textStyle="bold" />
            </LinearLayout>

        </androidx.cardview.widget.CardView>
        <!-- Column 2 -->
        <androidx.cardview.widget.CardView

            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_rowWeight="1"
            android:layout_columnWeight="1"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:layout_marginBottom="16dp"
            app:cardCornerRadius="8dp"
            app:cardElevation="5dp">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal|center_vertical"
                android:layout_margin="16dp"
                android:orientation="vertical">

                <ImageView
                    android:id="@+id/chartYoga"
                    android:layout_width="120dp"
                    android:layout_height="120dp"
                    android:layout_gravity="center_horizontal"
                    android:src="@drawable/ic_collections_bookmark_black_24dp" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="Yoga"
                    android:textColor="@android:color/black"
                    android:textSize="18sp"
                    android:textStyle="bold" />
            </LinearLayout>

        </androidx.cardview.widget.CardView>

        <!--  Row 3 -->

        <!-- Column 1 -->
        <androidx.cardview.widget.CardView

            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_rowWeight="1"
            android:layout_columnWeight="1"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:layout_marginBottom="16dp"
            app:cardCornerRadius="8dp"
            app:cardElevation="5dp">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal|center_vertical"
                android:layout_margin="16dp"
                android:orientation="vertical">

                <ImageView
                    android:id="@+id/chartRunning"
                    android:layout_width="120dp"
                    android:layout_height="120dp"
                    android:layout_gravity="center_horizontal"
                    android:src="@drawable/ic_collections_bookmark_black_24dp" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="Running"
                    android:textColor="@android:color/black"
                    android:textSize="18sp"
                    android:textStyle="bold" />
            </LinearLayout>

        </androidx.cardview.widget.CardView>
        <!-- Column 2 -->
        <androidx.cardview.widget.CardView

            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_rowWeight="1"
            android:layout_columnWeight="1"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:layout_marginBottom="16dp"
            app:cardCornerRadius="8dp"
            app:cardElevation="5dp">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal|center_vertical"
                android:layout_margin="16dp"
                android:orientation="vertical">

                <ImageView
                    android:id="@+id/chartWorkout"
                    android:layout_width="120dp"
                    android:layout_height="120dp"
                    android:layout_gravity="center_horizontal"
                    android:src="@drawable/ic_collections_bookmark_black_24dp" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="Workout"
                    android:textColor="@android:color/black"
                    android:textSize="18sp"
                    android:textStyle="bold" />
            </LinearLayout>

        </androidx.cardview.widget.CardView>

    </GridLayout>

</LinearLayout>
</code>```

with build gradle:

```<code>apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.something"
        minSdkVersion 14
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'androidx.cardview:cardview:1.0.0'

}
</code>```

Also I do not know your drawables, check also that they do not have a black background, if still does not work

Body:
Hello guys I have designed a GridLayout with CardViews to make a Dashboard but  the TextViews of the items are not showing in the emulator and a real device.. in the designer view it are showing but when I run it those TextView are not showing.. what could happen?
Here is my blueprint view:

And this is the UI design:

as we can see the textview if they are showing in the user interface..
Here is my code of the xml layout:

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
    android:weightSum="10"
    android:background="@drawable/header_background2"
    tools:context=".MainActivity">

    <RelativeLayout
        android:layout_weight="1"
        android:layout_width="match_parent"
        android:layout_height="0dp">
    <TextView
        android:id="@+id/textGrid"
        android:text="GRID LAYOUT"
        android:textSize="30sp"
        android:textStyle="bold"
        android:textColor="@android:color/white"
        android:layout_centerInParent="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

    </RelativeLayout>

    <GridLayout
        android:columnCount="2"
        android:rowCount="3"
        android:alignmentMode="alignMargins"
        android:columnOrderPreserved="false"
        android:layout_weight="8"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:padding="10dp">

            <androidx.cardview.widget.CardView
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:layout_columnWeight="1"
                android:layout_rowWeight="1"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                app:cardCornerRadius="8dp"
                app:cardElevation="5dp">

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal|center_vertical"
                    android:layout_margin="16dp"
                    android:orientation="vertical">

                    <ImageView
                        android:id="@+id/chartDiet"
                        android:layout_width="120dp"
                        android:layout_height="120dp"
                        android:layout_gravity="center_horizontal"
                        android:src="@drawable/diet" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:text="Dieta"
                        android:textColor="@android:color/black"
                        android:textSize="18sp"
                        android:textStyle="bold" />
                </LinearLayout>

            </androidx.cardview.widget.CardView>

            <androidx.cardview.widget.CardView
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:layout_rowWeight="1"
                android:layout_columnWeight="1"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_marginBottom="16dp"
                app:cardCornerRadius="8dp"
                app:cardElevation="5dp">

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal|center_vertical"
                    android:layout_margin="16dp"
                    android:orientation="vertical">

                    <ImageView
                        android:id="@+id/chartExercise"
                        android:layout_width="120dp"
                        android:layout_height="120dp"
                        android:layout_gravity="center_horizontal"
                        android:src="@drawable/exercise" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:text="Exercise"
                        android:textColor="@android:color/black"
                        android:textSize="18sp"
                        android:textStyle="bold" />
                </LinearLayout>

            </androidx.cardview.widget.CardView>

            <androidx.cardview.widget.CardView
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:layout_rowWeight="1"
                android:layout_columnWeight="1"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_marginBottom="16dp"
                app:cardCornerRadius="8dp"
                app:cardElevation="5dp">

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal|center_vertical"
                    android:layout_margin="16dp"
                    android:orientation="vertical">

                    <ImageView
                        android:id="@+id/chartMeditation"
                        android:layout_width="120dp"
                        android:layout_height="120dp"
                        android:layout_gravity="center_horizontal"
                        android:src="@drawable/meditation" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:text="Meditation"
                        android:textColor="@android:color/black"
                        android:textSize="18sp"
                        android:textStyle="bold" />
                </LinearLayout>

            </androidx.cardview.widget.CardView>

            <androidx.cardview.widget.CardView
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:layout_rowWeight="1"
                android:layout_columnWeight="1"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_marginBottom="16dp"
                app:cardCornerRadius="8dp"
                app:cardElevation="5dp">

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal|center_vertical"
                    android:layout_margin="16dp"
                    android:orientation="vertical">

                    <ImageView
                        android:id="@+id/chartYoga"
                        android:layout_width="120dp"
                        android:layout_height="120dp"
                        android:layout_gravity="center_horizontal"
                        android:src="@drawable/yoga" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:text="Yoga"
                        android:textColor="@android:color/black"
                        android:textSize="18sp"
                        android:textStyle="bold" />
                </LinearLayout>

            </androidx.cardview.widget.CardView>

        <androidx.cardview.widget.CardView
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_rowWeight="1"
            android:layout_columnWeight="1"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:layout_marginBottom="16dp"
            app:cardCornerRadius="8dp"
            app:cardElevation="5dp">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal|center_vertical"
                android:layout_margin="16dp"
                android:orientation="vertical">

                <ImageView
                    android:id="@+id/chartRunning"
                    android:layout_width="120dp"
                    android:layout_height="120dp"
                    android:layout_gravity="center_horizontal"
                    android:src="@drawable/running" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="Running"
                    android:textColor="@android:color/black"
                    android:textSize="18sp"
                    android:textStyle="bold" />
            </LinearLayout>

        </androidx.cardview.widget.CardView>

        <androidx.cardview.widget.CardView
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_rowWeight="1"
            android:layout_columnWeight="1"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:layout_marginBottom="16dp"
            app:cardCornerRadius="8dp"
            app:cardElevation="5dp">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal|center_vertical"
                android:layout_margin="16dp"
                android:orientation="vertical">

                <ImageView
                    android:id="@+id/chartWorkout"
                    android:layout_width="120dp"
                    android:layout_height="120dp"
                    android:layout_gravity="center_horizontal"
                    android:src="@drawable/workout"
                    />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="Workout"
                    android:textColor="@android:color/black"
                    android:textSize="18sp"
                    android:textStyle="bold" />
            </LinearLayout>

        </androidx.cardview.widget.CardView>

    </GridLayout>

</LinearLayout>

Someone can help me i don't know where is the error.. or i have a bad design and maybe I should start again with another project using ConstraintLayout like root element..
thanks..
PD: the code for every row is the same only change the image and textview

Body:
Is working on my emulator
my dependency in build.gradle is
    implementation 'androidx.cardview:cardview:1.0.0'
please try to change to

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
    android:weightSum="10"
    tools:context=".MainActivity">

    <RelativeLayout
        android:layout_weight="1"
        android:layout_width="match_parent"
        android:layout_height="0dp">
        <TextView
            android:id="@+id/textGrid"
            android:text="GRID LAYOUT"
            android:textSize="30sp"
            android:textStyle="bold"
            android:textColor="@android:color/white"
            android:layout_centerInParent="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>

    </RelativeLayout>

    <GridLayout
        android:columnCount="2"
        android:rowCount="3"
        android:alignmentMode="alignMargins"
        android:columnOrderPreserved="false"
        android:layout_weight="8"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:padding="10dp">
        <!--  Row 1 -->
        <!-- Column 1 -->
        <androidx.cardview.widget.CardView
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_columnWeight="1"
            android:layout_rowWeight="1"
            android:layout_marginBottom="16dp"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            app:cardCornerRadius="8dp"
            app:cardElevation="5dp">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal|center_vertical"
                android:layout_margin="16dp"
                android:orientation="vertical">

                <ImageView
                    android:id="@+id/chartDiet"
                    android:layout_width="120dp"
                    android:layout_height="120dp"
                    android:layout_gravity="center_horizontal"
                    android:src="@drawable/ic_collections_bookmark_black_24dp" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="Dieta"
                    android:textColor="@android:color/black"
                    android:textSize="18sp"
                    android:textStyle="bold" />
            </LinearLayout>

        </androidx.cardview.widget.CardView>
        <!-- Column 2 -->
        <androidx.cardview.widget.CardView

            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_rowWeight="1"
            android:layout_columnWeight="1"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:layout_marginBottom="16dp"
            app:cardCornerRadius="8dp"
            app:cardElevation="5dp">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal|center_vertical"
                android:layout_margin="16dp"
                android:orientation="vertical">

                <ImageView
                    android:id="@+id/chartExercise"
                    android:layout_width="120dp"
                    android:layout_height="120dp"
                    android:layout_gravity="center_horizontal"
                    android:src="@drawable/ic_collections_bookmark_black_24dp" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="Exercise"
                    android:textColor="@android:color/black"
                    android:textSize="18sp"
                    android:textStyle="bold" />
            </LinearLayout>

        </androidx.cardview.widget.CardView>

        <!--  Row 2 -->
        <!-- Column 1 -->
        <androidx.cardview.widget.CardView

            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_rowWeight="1"
            android:layout_columnWeight="1"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:layout_marginBottom="16dp"
            app:cardCornerRadius="8dp"
            app:cardElevation="5dp">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal|center_vertical"
                android:layout_margin="16dp"
                android:orientation="vertical">

                <ImageView
                    android:id="@+id/chartMeditation"
                    android:layout_width="120dp"
                    android:layout_height="120dp"
                    android:layout_gravity="center_horizontal"
                    android:src="@drawable/ic_collections_bookmark_black_24dp" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="Meditation"
                    android:textColor="@android:color/black"
                    android:textSize="18sp"
                    android:textStyle="bold" />
            </LinearLayout>

        </androidx.cardview.widget.CardView>
        <!-- Column 2 -->
        <androidx.cardview.widget.CardView

            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_rowWeight="1"
            android:layout_columnWeight="1"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:layout_marginBottom="16dp"
            app:cardCornerRadius="8dp"
            app:cardElevation="5dp">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal|center_vertical"
                android:layout_margin="16dp"
                android:orientation="vertical">

                <ImageView
                    android:id="@+id/chartYoga"
                    android:layout_width="120dp"
                    android:layout_height="120dp"
                    android:layout_gravity="center_horizontal"
                    android:src="@drawable/ic_collections_bookmark_black_24dp" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="Yoga"
                    android:textColor="@android:color/black"
                    android:textSize="18sp"
                    android:textStyle="bold" />
            </LinearLayout>

        </androidx.cardview.widget.CardView>

        <!--  Row 3 -->

        <!-- Column 1 -->
        <androidx.cardview.widget.CardView

            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_rowWeight="1"
            android:layout_columnWeight="1"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:layout_marginBottom="16dp"
            app:cardCornerRadius="8dp"
            app:cardElevation="5dp">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal|center_vertical"
                android:layout_margin="16dp"
                android:orientation="vertical">

                <ImageView
                    android:id="@+id/chartRunning"
                    android:layout_width="120dp"
                    android:layout_height="120dp"
                    android:layout_gravity="center_horizontal"
                    android:src="@drawable/ic_collections_bookmark_black_24dp" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="Running"
                    android:textColor="@android:color/black"
                    android:textSize="18sp"
                    android:textStyle="bold" />
            </LinearLayout>

        </androidx.cardview.widget.CardView>
        <!-- Column 2 -->
        <androidx.cardview.widget.CardView

            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_rowWeight="1"
            android:layout_columnWeight="1"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:layout_marginBottom="16dp"
            app:cardCornerRadius="8dp"
            app:cardElevation="5dp">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal|center_vertical"
                android:layout_margin="16dp"
                android:orientation="vertical">

                <ImageView
                    android:id="@+id/chartWorkout"
                    android:layout_width="120dp"
                    android:layout_height="120dp"
                    android:layout_gravity="center_horizontal"
                    android:src="@drawable/ic_collections_bookmark_black_24dp" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="Workout"
                    android:textColor="@android:color/black"
                    android:textSize="18sp"
                    android:textStyle="bold" />
            </LinearLayout>

        </androidx.cardview.widget.CardView>

    </GridLayout>

</LinearLayout>

with build gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.something"
        minSdkVersion 14
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'androidx.cardview:cardview:1.0.0'

}

Also I do not know your drawables, check also that they do not have a black background, if still does not work


来源: stackexchange

问:
VSCode IntelliSense not recognising SDL_image extension library for SDL framework
I am trying to include the SDL_image extension library to SDL.framework in my project but VScode's IntelliSense keeps underlining my #include<SDL_image.h> with error lines. It produces the following error:

```<code>cannot open source file "SDL2/SDL.h" (dependency of "SDL_image.h")
</code>```

I was successfully able to edit the c_cpp_properties.json includePath so IntelliSense recognised the SDL framework, but when trying to do the same thing with SLD_image it failed.

This is my c_cpp_properties.json file:

```<code>{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "/Library/Frameworks/SDL2_image.framework/Headers",
                "/Library/Frameworks/SDL2.framework/Headers",
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "macFrameworkPath": [
                "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
            ],
            "compilerPath": "/usr/bin/clang",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "clang-x64"
        }
    ],
    "version": 4
}
</code>```

答:
The problem wasn't with the c_cpp_properties.json but the SDL_image.h file. If you are using VScode (despite being on a mac) and encountering the same issue with IntelliSense, change the following include statements inside SDL_image.h from this:

```<code>#include <SDL2/SDL.h>
#include <SDL2/SDL_version.h>
#include <SDL2/begin_code.h>
#include <SDL2/close_code.h>
</code>```

to this:

```<code>#include <SDL.h>
#include <SDL_version.h>
#include <begin_code.h>
#include <close_code.h>
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I am trying to include the SDL_image extension library to SDL.framework in my project but VScode's IntelliSense keeps underlining my #include<SDL_image.h> with error lines. It produces the following error:

cannot open source file "SDL2/SDL.h" (dependency of "SDL_image.h")

I was successfully able to edit the c_cpp_properties.json includePath so IntelliSense recognised the SDL framework, but when trying to do the same thing with SLD_image it failed.

This is my c_cpp_properties.json file:

{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "/Library/Frameworks/SDL2_image.framework/Headers",
                "/Library/Frameworks/SDL2.framework/Headers",
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "macFrameworkPath": [
                "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
            ],
            "compilerPath": "/usr/bin/clang",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "clang-x64"
        }
    ],
    "version": 4
}

Body:
The problem wasn't with the c_cpp_properties.json but the SDL_image.h file. If you are using VScode (despite being on a mac) and encountering the same issue with IntelliSense, change the following include statements inside SDL_image.h from this:

#include <SDL2/SDL.h>
#include <SDL2/SDL_version.h>
#include <SDL2/begin_code.h>
#include <SDL2/close_code.h>

to this:

#include <SDL.h>
#include <SDL_version.h>
#include <begin_code.h>
#include <close_code.h>


问:
Function format representation form recognicion
Is it possible to get info about the representation of a number being passed to a function?
For example if I pass 0x14 (hex) or 0b10100 (binary), Python at some point must be aware (I guess) that I passed a number with that representation before it gets saved into an internal data format.

Can I access this information in order to handle the number as hex, binary, decimal (etc) when I want to print it inside the function (where this information is not directly available).

答: Building off of what jonrsharpe noted in the comments, the literals 0x14 and 0b10100 in Python are both evaluated into plain old Python integer objects (i.e., PyLongObject). Once this parsing occurs (at compile time), the origin "format" used to represent the value in text is completely forgotten. If you want a function to behave different for "hex" numbers versus "binary" numbers, you'll have to either represent these values as strings instead of numbers, or pass an additional argument indicating the desired representation.


问:
How to pass a Dictionary in a web service
I have created a simple service to provide configuration options as a Dictionary. I created a new SerializableDictionary class that implements IXmlSerializable as described on this board. When I add the service (via "Add Service Reference" in my consumer project), the method signature shows that it returns a DataSet. When I examine the DataSet at runtime it is empty.

Here is my service:

```<code>[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class AppSettingsService : System.Web.Services.WebService
{
        [WebMethod]
        public SerializableDictionary<string, string> ReadAppSettings()
        {
            return AppSettings.Settings; // Settings is a SerializableDictionary<string, string>
        }
}
</code>```

On the Client side I do this:

```<code>using Clients.AppSettingsServiceReference;

        static AppSettings()
        {
            AppSettingsServiceSoapClient client = new AppSettingsServiceSoapClient();
            var settings = client.ReadAppSettings();
            // ...
        }
</code>```

I expect settings to be a SerializableDictionary but it's an empty DataSet. I've tried sending it as a List of KeyValuePairs as suggested here and elsewhere but that also returns a DataSet. I'm using C#, ASP.Net 3.5, VS2008 Pro
I'm sure I'm overlooking something simple but I can't find it. Can someone show me how to do this?

答:
In general, web services of any kind do not understand data types which are specific to the platform you're running on.

In particular, there's no general concept of "dictionary", so web services don't understand them.

More to the point, there's no way to get anything like a dictionary across ASMX web services. If you were using WCF (as you should be doing for all new development), then you could use the same types on the client as on the service.

Of course, you'd still have the same problem if your client and service are not both running .NET.

ContentLicense: CC BY-SA 3.0

Body:
I have created a simple service to provide configuration options as a Dictionary. I created a new SerializableDictionary class that implements IXmlSerializable as described on this board. When I add the service (via "Add Service Reference" in my consumer project), the method signature shows that it returns a DataSet. When I examine the DataSet at runtime it is empty.

Here is my service:

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class AppSettingsService : System.Web.Services.WebService
{
        [WebMethod]
        public SerializableDictionary<string, string> ReadAppSettings()
        {
            return AppSettings.Settings; // Settings is a SerializableDictionary<string, string>
        }
}

On the Client side I do this:

using Clients.AppSettingsServiceReference;

        static AppSettings()
        {
            AppSettingsServiceSoapClient client = new AppSettingsServiceSoapClient();
            var settings = client.ReadAppSettings();
            // ...
        }

I expect settings to be a SerializableDictionary but it's an empty DataSet. I've tried sending it as a List of KeyValuePairs as suggested here and elsewhere but that also returns a DataSet. I'm using C#, ASP.Net 3.5, VS2008 Pro
I'm sure I'm overlooking something simple but I can't find it. Can someone show me how to do this?


问:
Runtime of classic Cracking the Coding Interview question a^3 + b^3 = c^3 + d^3?
Hi I am going over Gayle Laakmann's CTIC book and I came across her question

```<code>print all possible integer solutions for a^3 + b^3 = c^3 + d^3 where a,b,c,d can be integers 1 - 1000
</code>```

She gave some pseudo code which looks like this:

First solution

```<code>n = 1000
for c from 1 to n
   for d from 1 to n
      result = c^3 + d^3
      append(c,d) to list at value map[result]

for a from 1 to n
   for b from 1 to n
      result = a^3 + b^3
      list = map.get(result)
      for each pair in list
         print a, b, pair
</code>```

Second Solution

```<code>n = 1000
for c from 1 to n
   for d from 1 to n
      result = c^3 + d^3
      append (c,d) to list at value map[result]

for each result, list in map
   for each pair1 in list
      for each pair2 in list
         print pair1, pair2
</code>```

How do any of these solutions get an O(n^2) running time? Even in the first solution the second set of for loops you also iterate over the pairs in your map so wouldn't that be O(n^3)?

答:
If r(m) is the number of ordered representations of m as the sum of two positive integer cubes, then it is known that sum(r(m)^2, m=0..M) is Theta(M^(2/3)), see [1].

This implies that the number of solutions your algorithm will print is O(n^2), because the largest possible sum of two cubes you will generate is 2*N^3 and the maximum number of solutions for a given m is r(m)^2 to account for all combinations of the representations on both sides of the equation.

Because the innermost loop always iterates exactly ones per printed result, it is then also only executed at most O(n^2) times, making the whole algorithm Theta(n^2) (due to the outer loops iteration time).

[1] Hooley (1963): On the representations of a number as the sum of two cubes; https://link.springer.com/article/10.1007/BF01111429

Body:
Hi I am going over Gayle Laakmann's CTIC book and I came across her question

print all possible integer solutions for a^3 + b^3 = c^3 + d^3 where a,b,c,d can be integers 1 - 1000

She gave some pseudo code which looks like this:

First solution

n = 1000
for c from 1 to n
   for d from 1 to n
      result = c^3 + d^3
      append(c,d) to list at value map[result]

for a from 1 to n
   for b from 1 to n
      result = a^3 + b^3
      list = map.get(result)
      for each pair in list
         print a, b, pair

Second Solution

n = 1000
for c from 1 to n
   for d from 1 to n
      result = c^3 + d^3
      append (c,d) to list at value map[result]

for each result, list in map
   for each pair1 in list
      for each pair2 in list
         print pair1, pair2

How do any of these solutions get an O(n^2) running time? Even in the first solution the second set of for loops you also iterate over the pairs in your map so wouldn't that be O(n^3)?


问:
In python, I'm trying to count each element in a list using a for loop, but it returns the element occurrence n many times
This function returns the element occurrence n many times:

```<code>def cold_compress():
    l = int(input())
    inp_list = []
    num_list = []
    for lines in range(l):
        b = input()
        inp_list.append(b)
        print(b)

    for item in inp_list:
        for x in item:
            print(item.count(x))
</code>```

For example:
if my input is:

eeewwww

33jjji

...it will output:

3

3

3

4

4

4

4

2

2

3

3

3

1

How do I avoid this?

答:
You can use Counter() to count the elements inside a list

Sample code:

```<code>from collections import Counter
listr = ["one","two","three","three","three","three",]

print(dict(Counter(listr)))
</code>```

OUTPUT

```<code>{'one': 1, 'two': 1, 'three': 4}
</code>```

Implementing the Counter() in your code:

```<code>from collections import Counter

def cold_compress():
    listr = list(input())
    print(dict(Counter(listr)))

cold_compress()
</code>```

Body:
This function returns the element occurrence n many times:

def cold_compress():
    l = int(input())
    inp_list = []
    num_list = []
    for lines in range(l):
        b = input()
        inp_list.append(b)
        print(b)

    for item in inp_list:
        for x in item:
            print(item.count(x))

For example:
if my input is:

eeewwww

33jjji

...it will output:

3

3

3

4

4

4

4

2

2

3

3

3

1

How do I avoid this?

Body:
You can use Counter() to count the elements inside a list

Sample code:

from collections import Counter
listr = ["one","two","three","three","three","three",]

print(dict(Counter(listr)))

OUTPUT

{'one': 1, 'two': 1, 'three': 4}

Implementing the Counter() in your code:

from collections import Counter

def cold_compress():
    listr = list(input())
    print(dict(Counter(listr)))

cold_compress()


问:
New to MATLAB. Getting the error First input argument must be a function handle. While attempting to integrate current function
So this is what I have so far

```<code>t=60;

q=integral(e(t)*i(t), t, 0, 2*pi);

function v=e(t)

v=160*sin(t);

end

function c=i(t)

c=2*sin(t-(pi/6));

end
</code>```

but it is returning the following errors and I have no idea how to fix it. I've looked at other posts referencing the same error and I haven't been able to fix it.

```<code>Error using integral (line 82)
First input argument must be a function handle.

Error (line 10)
q=integral(e(t)*i(t), t, 0, 2*pi);
</code>```

Any help will be greatly appreciated

答:
You should have something like this:

```<code>e_times_i = @(t) e(t) .* i(t)
q=integral(e_times_i, 0, 2*pi);
</code>```

Indeed, the first argument of integral matlab function handle. You gave value not the function handle.

Body:
So this is what I have so far

t=60;

q=integral(e(t)*i(t), t, 0, 2*pi);

function v=e(t)

v=160*sin(t);

end

function c=i(t)

c=2*sin(t-(pi/6));

end

but it is returning the following errors and I have no idea how to fix it. I've looked at other posts referencing the same error and I haven't been able to fix it.

Error using integral (line 82)
First input argument must be a function handle.

Error (line 10)
q=integral(e(t)*i(t), t, 0, 2*pi);

Any help will be greatly appreciated

Body:
You should have something like this:

e_times_i = @(t) e(t) .* i(t)
q=integral(e_times_i, 0, 2*pi);

Indeed, the first argument of integral matlab function handle. You gave value not the function handle.


问:
Cache anonymous HTTP requests (based on cookies)
I would like to add a HTTP (or WSGI) cache to my Python web application, for all requests which

are either GET or HEAD

do not have a cookie called "session_id" (known users get specialized, non-cacheable pages)

do not have a cookie called "_flash" (this cookie is used to show the user some short messages like "article created successfully", even after a redirect)

if there are cookies which start with "__utm" (created by Google Analytics) they should be ignored (not stored in the cache), but the site should still be cached

If additional common caching directives (like cache-control: private) or even ETAGS are taken into account it would be nice too, but that is currently not a requirement.

Preferable, I do not want to run any additional piece of software like Squid (but I will use it if there a good reasons to do so), so I will prefer a mod_apache based solution, or even some kind of memcached powered WSGI-Middleware; Other solutions are also welcome.

Many thanks,

Christoph

答: I'd recommend checking out varnish. It's going to be a lot faster than any WSGI-Middleware you write/find, and you should be able to do everything you want with it. Here's the tutorial for a taste of it's many features, options: http://www.varnish-cache.org/docs/trunk/tutorial/index.html</p>


问:
Optimize API for reducing the segments and eliminating ES deleted docs not working
This is in continuation of my previous question Does huge number of deleted doc count affects ES query performance related to deleted docs in my ES index.

As pointed in the answer, I used optimize API as I am using the ES 1.X version where force merge API is not available but after reading about optimize API github link(provided earlier as couldn't find it on ES site) by Say Bannon founder of elastic, looks like it does the same work.

I got the success message for my index after running the optimize API, but I don't see total count of deleted docs decreasing and I am worried as when I checked the segments of my index using segments API, I see there are more than 25 segments for each shard and every shard is holding 250-1 gb of data in memory and almost 500k docs, while I see there are some shards where there is few deleted docs.

So my question are:

My index is having multiple shards across multiple data nodes and when  I ran optimize API using only 1 node URL, then does it only merges the segments on that node?

In segment API result it shows the node-id like "node": "f2hsqeamadnaskda", while I am using KOPF plugin and have custom names for my data nodes, so How can I relate this cryptic node name to my human readable node name to identify whether statement 1 is correct or not?

As there is no documentation available on optimize API, is it possible to merge segments on all shards across all nodes in single shot? and do I need to make index read-only before applying it?

答:
force_merge or optimize call gets applied to entire index, you dont have to do them at node level.

You can use _cat api to find out nodeid:Ip mapping.In case your version does not support _cat api ( < 1.0) , use cluster state api


问:
Why am I getting these errors when I am trying to compile my C code?
I am getting this error when compiling: </p>

```<code>browninz.buildrooms.c:191:29: error: expected expression before â€˜structâ€™
         AddRandomConnection(struct room RoomA.outboundConnections, struct room RoomB.outboundConnections);
                             ^
browninz.buildrooms.c:191:29: error: too few arguments to function â€˜AddRandomConnectionâ€™
browninz.buildrooms.c:40:6: note: declared here
 void AddRandomConnection(struct room *RoomA, struct room *RoomB)
      ^
</code>```

<p>Originally I started with about 20+ errors and I have finally scaled it down to a single error within my AddRandomConnections method, I am trying to compile this code and it keeps throwing an error for this single line. I have been trying for a few hours for different methods to fix the error, but I cannot get it to go away. Can anyone help me figure out why I am getting this error?
Here is my code: </p>

```<code>#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
/*#include <stdbool.h>*/

typedef enum
{
    false,
    true
} bool;
// Creating the template for each of the rooms via struct
struct room
{
    int id;
    char* name;
    char* type;
    int numOutboundConnections;
    struct room* outboundConnections[5];
};

// Returns true if all rooms have 3 to 6 outbound connections, false otherwise
int IsGraphFull(struct room *structureRooms)
{
    int k = 0;
    while (k < 7){
        if (sizeof(structureRooms[k].numOutboundConnections) < 3){
            return 0;
        }
        k++;
    }
    return 1;
}
// Adds a random outbound connection between two rooms
void AddRandomConnection(struct room *RoomA, struct room *RoomB)
{
    while(true)
    {
        RoomA = GetRandomRoom(RoomA);

        if (CanAddConnectionFrom(RoomA) == true)
            break;
    }
    do
    {
        RoomB = GetRandomRoom(RoomB);
    }
    while(CanAddConnectionFrom(RoomB) == false || IsSameRoom(RoomA, RoomB) == true || ConnectionAlreadyExists(RoomA, RoomB) == true);

    ConnectRoom(RoomA, RoomB); // TODO: Add this connection to the real variables,
    ConnectRoom(RoomB, RoomA); // because this A and B will be destroyed when this function terminates
}

// Returns a random Room, does NOT validate if connection can be added
int GetRandomRoom(struct room *connections[])
{
    // Initializes random number generator
    srand(time(0));
    // Generate random room
    int x = rand() % 7;
    return x;
}

// Returns true if a connection can be added from Room x (< 6 outbound connections), false otherwise
int CanAddConnectionFrom(struct room *RoomA)
{
    if (sizeof(RoomA->numOutboundConnections) < 6)
    {
        return 1;
    }
    else{
        return 0;
    }
}
// Returns true if a connection from Room x and Room y already exists, false otherwise
int ConnectionAlreadyExists(struct room *RoomA, struct room *RoomB)
{
    int myConnections;
    int i = 0;
    for (i; i <= 6; i++){
        if ((RoomA->numOutboundConnections = RoomB->id)){
            myConnections = 1;
            break;
        }
        if(myConnections == 1)
        {
            return 1;
        }
        else
            return 0;
            }
}
// Connects Rooms A and B together, does not check if this connection is valid
void ConnectRoom(struct room *RoomA, struct room *RoomB)
{
    RoomA->numOutboundConnections = RoomB->id;
}
// Returns true if Rooms x and y are the same Room, false otherwise
int IsSameRoom(struct room *RoomA, struct room *RoomB)
{
   if (strcmp(RoomA->name, RoomB->name) == 0){
    return 1;
   }
   return 0;
}

int main(int argc, char* argv[])
{
// Room names
char Forest[] = "Forest";
char Beach[] = "Beach";
char Cliff[] = "Cliff";
char River[] = "River";
char Cave[] = "Cave";
char Mountain[] = "Mountain";
char Cabin[] = "Cabin";
char Castle[] = "Castle";
char Fountain[] = "Fountain";
char Homeria[] = "Homeria";
// Initializing a room array variable to store contents of all room names
char* roomName[] = {Forest, Beach, Cliff, River, Cave, Mountain, Cabin, Castle, Fountain, Homeria};
// Creating the structs of 7 rooms each labeled with a name and type slot

    struct room Room1;
    Room1.id = 1;
    Room1.name = calloc(16, sizeof(char));
    Room1.type = calloc(16, sizeof(char));
    strcpy(Room1.type, "START_ROOM");

    struct room Room2;
    Room2.id = 2;
    Room2.name = calloc(16, sizeof(char));
    Room2.type = calloc(16, sizeof(char));
    strcpy(Room2.type, "MID_ROOM");

    struct room Room3;
    Room3.id = 3;
    Room3.name = calloc(16, sizeof(char));
    Room3.type = calloc(16, sizeof(char));
    strcpy(Room3.type, "MID_ROOM");

    struct room Room4;
    Room4.id = 4;
    Room4.name = calloc(16, sizeof(char));
    Room4.type = calloc(16, sizeof(char));
    strcpy(Room4.type, "MID_ROOM");

    struct room Room5;
    Room5.id = 5;
    Room5.name = calloc(16, sizeof(char));
    Room5.type = calloc(16, sizeof(char));
    strcpy(Room5.type, "MID_ROOM");

    struct room Room6;
    Room6.id = 6;
    Room6.name = calloc(16, sizeof(char));
    Room6.type = calloc(16, sizeof(char));
    strcpy(Room6.type, "MID_ROOM");

    struct room Room7;
    Room7.id = 10;
    Room7.name = calloc(16, sizeof(char));
    Room7.type = calloc(16, sizeof(char));
    strcpy(Room7.type, "END_ROOM");

// Randomizing the room names to append to a random room #
    srand(time(0));
    struct room structureRooms[7] = {Room1, Room2, Room3, Room4, Room5, Room6, Room7};
    int i = 0;
    int array1[] = {0 ,0, 0, 0, 0, 0, 0, 0, 0, 0};
    // Loop for each of the rooms which checks to see if a name is available, if so, apply to random room
    while ( i < 7 ){
        int randNum = rand() % 10;
        if (array1[randNum] == 0){
            array1[randNum] = 1;
            strcpy(structureRooms[i].name, roomName[randNum]);
            i++;
        }
    }
     // Create all connections in the graph
    while (IsGraphFull(structureRooms) == false)
    {
        AddRandomConnection(struct room RoomA.outboundConnections, struct room RoomB.outboundConnections);
    }
    // Assigning char limits
    char dirname[100];
    char dir0[100];
    char dir1[100];
    char dir2[100];
    char dir3[100];
    char dir4[100];
    char dir5[100];
    char dir6[100];

    // Generate the "rooms" directory name with the PID
    sprintf(dirname, "./browninz.rooms%d", getpid());

    // Generate the room names concatenated with the directory name
    sprintf(dir0, "%s/Room1", dirname);
    sprintf(dir1, "%s/Room2", dirname);
    sprintf(dir2, "%s/Room3", dirname);
    sprintf(dir3, "%s/Room4", dirname);
    sprintf(dir4, "%s/Room5", dirname);
    sprintf(dir5, "%s/Room6", dirname);
    sprintf(dir6, "%s/Room7", dirname);

    // Create a new directory that the "rooms" files will be stored in
    mkdir(dirname, 0770);

    // Pointer files of each of the rooms
    FILE *myRoom1;
    FILE *myRoom2;
    FILE *myRoom3;
    FILE *myRoom4;
    FILE *myRoom5;
    FILE *myRoom6;
    FILE *myRoom7;
    // Now opening the room files / directories to create or write them in the folder.
    myRoom1 = fopen(dir0, "w+");
    myRoom2 = fopen(dir1, "w+");
    myRoom3 = fopen(dir2, "w+");
    myRoom4 = fopen(dir3, "w+");
    myRoom5 = fopen(dir4, "w+");
    myRoom6 = fopen(dir5, "w+");
    myRoom7 = fopen(dir6, "w+");
    // Creating a pointer array of all of the room pointers
    FILE *myRooms[7] = {myRoom1, myRoom2, myRoom3, myRoom4, myRoom5, myRoom6, myRoom7};
    // Printing room file name, type, and connections and iterates for each room
    int counter = 0;
    while (counter < 7) {
        fprintf(myRooms[counter], "ROOM NAME: %s\n", structureRooms[counter].name);
        fprintf(myRooms[counter], "ROOM TYPE: %s\n", structureRooms[counter].type);
       // fprintf(myRooms[counter], "CONNECTION 1: %s\n", structureRooms[counter].outboundConnections[counter]);
       // test to see if connection works
        fprintf(myRooms[counter], "CONNECTION 1: %s\n", structureRooms[counter].name);
        counter++;
    }
    return 0;
    }
</code>```

答:
In your call below, remove the "struct room".  You've already declared the type in the function declaration.

```<code>// Create all connections in the graph
while (IsGraphFull(structureRooms) == false)
{
    AddRandomConnection(struct room RoomA.outboundConnections, struct room RoomB.outboundConnections);
}
</code>```

So that it is just AddRandommConnection(RoomA.outboundConnections, Roomb.outboundConnections);

Body:
I am getting this error when compiling:

browninz.buildrooms.c:191:29: error: expected expression before â€˜structâ€™
         AddRandomConnection(struct room RoomA.outboundConnections, struct room RoomB.outboundConnections);
                             ^
browninz.buildrooms.c:191:29: error: too few arguments to function â€˜AddRandomConnectionâ€™
browninz.buildrooms.c:40:6: note: declared here
 void AddRandomConnection(struct room *RoomA, struct room *RoomB)
      ^

Originally I started with about 20+ errors and I have finally scaled it down to a single error within my AddRandomConnections method, I am trying to compile this code and it keeps throwing an error for this single line. I have been trying for a few hours for different methods to fix the error, but I cannot get it to go away. Can anyone help me figure out why I am getting this error?
Here is my code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
/*#include <stdbool.h>*/

typedef enum
{
    false,
    true
} bool;
// Creating the template for each of the rooms via struct
struct room
{
    int id;
    char* name;
    char* type;
    int numOutboundConnections;
    struct room* outboundConnections[5];
};

// Returns true if all rooms have 3 to 6 outbound connections, false otherwise
int IsGraphFull(struct room *structureRooms)
{
    int k = 0;
    while (k < 7){
        if (sizeof(structureRooms[k].numOutboundConnections) < 3){
            return 0;
        }
        k++;
    }
    return 1;
}
// Adds a random outbound connection between two rooms
void AddRandomConnection(struct room *RoomA, struct room *RoomB)
{
    while(true)
    {
        RoomA = GetRandomRoom(RoomA);

        if (CanAddConnectionFrom(RoomA) == true)
            break;
    }
    do
    {
        RoomB = GetRandomRoom(RoomB);
    }
    while(CanAddConnectionFrom(RoomB) == false || IsSameRoom(RoomA, RoomB) == true || ConnectionAlreadyExists(RoomA, RoomB) == true);

    ConnectRoom(RoomA, RoomB); // TODO: Add this connection to the real variables,
    ConnectRoom(RoomB, RoomA); // because this A and B will be destroyed when this function terminates
}

// Returns a random Room, does NOT validate if connection can be added
int GetRandomRoom(struct room *connections[])
{
    // Initializes random number generator
    srand(time(0));
    // Generate random room
    int x = rand() % 7;
    return x;
}

// Returns true if a connection can be added from Room x (< 6 outbound connections), false otherwise
int CanAddConnectionFrom(struct room *RoomA)
{
    if (sizeof(RoomA->numOutboundConnections) < 6)
    {
        return 1;
    }
    else{
        return 0;
    }
}
// Returns true if a connection from Room x and Room y already exists, false otherwise
int ConnectionAlreadyExists(struct room *RoomA, struct room *RoomB)
{
    int myConnections;
    int i = 0;
    for (i; i <= 6; i++){
        if ((RoomA->numOutboundConnections = RoomB->id)){
            myConnections = 1;
            break;
        }
        if(myConnections == 1)
        {
            return 1;
        }
        else
            return 0;
            }
}
// Connects Rooms A and B together, does not check if this connection is valid
void ConnectRoom(struct room *RoomA, struct room *RoomB)
{
    RoomA->numOutboundConnections = RoomB->id;
}
// Returns true if Rooms x and y are the same Room, false otherwise
int IsSameRoom(struct room *RoomA, struct room *RoomB)
{
   if (strcmp(RoomA->name, RoomB->name) == 0){
    return 1;
   }
   return 0;
}

int main(int argc, char* argv[])
{
// Room names
char Forest[] = "Forest";
char Beach[] = "Beach";
char Cliff[] = "Cliff";
char River[] = "River";
char Cave[] = "Cave";
char Mountain[] = "Mountain";
char Cabin[] = "Cabin";
char Castle[] = "Castle";
char Fountain[] = "Fountain";
char Homeria[] = "Homeria";
// Initializing a room array variable to store contents of all room names
char* roomName[] = {Forest, Beach, Cliff, River, Cave, Mountain, Cabin, Castle, Fountain, Homeria};
// Creating the structs of 7 rooms each labeled with a name and type slot

    struct room Room1;
    Room1.id = 1;
    Room1.name = calloc(16, sizeof(char));
    Room1.type = calloc(16, sizeof(char));
    strcpy(Room1.type, "START_ROOM");

    struct room Room2;
    Room2.id = 2;
    Room2.name = calloc(16, sizeof(char));
    Room2.type = calloc(16, sizeof(char));
    strcpy(Room2.type, "MID_ROOM");

    struct room Room3;
    Room3.id = 3;
    Room3.name = calloc(16, sizeof(char));
    Room3.type = calloc(16, sizeof(char));
    strcpy(Room3.type, "MID_ROOM");

    struct room Room4;
    Room4.id = 4;
    Room4.name = calloc(16, sizeof(char));
    Room4.type = calloc(16, sizeof(char));
    strcpy(Room4.type, "MID_ROOM");

    struct room Room5;
    Room5.id = 5;
    Room5.name = calloc(16, sizeof(char));
    Room5.type = calloc(16, sizeof(char));
    strcpy(Room5.type, "MID_ROOM");

    struct room Room6;
    Room6.id = 6;
    Room6.name = calloc(16, sizeof(char));
    Room6.type = calloc(16, sizeof(char));
    strcpy(Room6.type, "MID_ROOM");

    struct room Room7;
    Room7.id = 10;
    Room7.name = calloc(16, sizeof(char));
    Room7.type = calloc(16, sizeof(char));
    strcpy(Room7.type, "END_ROOM");

// Randomizing the room names to append to a random room #
    srand(time(0));
    struct room structureRooms[7] = {Room1, Room2, Room3, Room4, Room5, Room6, Room7};
    int i = 0;
    int array1[] = {0 ,0, 0, 0, 0, 0, 0, 0, 0, 0};
    // Loop for each of the rooms which checks to see if a name is available, if so, apply to random room
    while ( i < 7 ){
        int randNum = rand() % 10;
        if (array1[randNum] == 0){
            array1[randNum] = 1;
            strcpy(structureRooms[i].name, roomName[randNum]);
            i++;
        }
    }
     // Create all connections in the graph
    while (IsGraphFull(structureRooms) == false)
    {
        AddRandomConnection(struct room RoomA.outboundConnections, struct room RoomB.outboundConnections);
    }
    // Assigning char limits
    char dirname[100];
    char dir0[100];
    char dir1[100];
    char dir2[100];
    char dir3[100];
    char dir4[100];
    char dir5[100];
    char dir6[100];

    // Generate the "rooms" directory name with the PID
    sprintf(dirname, "./browninz.rooms%d", getpid());

    // Generate the room names concatenated with the directory name
    sprintf(dir0, "%s/Room1", dirname);
    sprintf(dir1, "%s/Room2", dirname);
    sprintf(dir2, "%s/Room3", dirname);
    sprintf(dir3, "%s/Room4", dirname);
    sprintf(dir4, "%s/Room5", dirname);
    sprintf(dir5, "%s/Room6", dirname);
    sprintf(dir6, "%s/Room7", dirname);

    // Create a new directory that the "rooms" files will be stored in
    mkdir(dirname, 0770);

    // Pointer files of each of the rooms
    FILE *myRoom1;
    FILE *myRoom2;
    FILE *myRoom3;
    FILE *myRoom4;
    FILE *myRoom5;
    FILE *myRoom6;
    FILE *myRoom7;
    // Now opening the room files / directories to create or write them in the folder.
    myRoom1 = fopen(dir0, "w+");
    myRoom2 = fopen(dir1, "w+");
    myRoom3 = fopen(dir2, "w+");
    myRoom4 = fopen(dir3, "w+");
    myRoom5 = fopen(dir4, "w+");
    myRoom6 = fopen(dir5, "w+");
    myRoom7 = fopen(dir6, "w+");
    // Creating a pointer array of all of the room pointers
    FILE *myRooms[7] = {myRoom1, myRoom2, myRoom3, myRoom4, myRoom5, myRoom6, myRoom7};
    // Printing room file name, type, and connections and iterates for each room
    int counter = 0;
    while (counter < 7) {
        fprintf(myRooms[counter], "ROOM NAME: %s\n", structureRooms[counter].name);
        fprintf(myRooms[counter], "ROOM TYPE: %s\n", structureRooms[counter].type);
       // fprintf(myRooms[counter], "CONNECTION 1: %s\n", structureRooms[counter].outboundConnections[counter]);
       // test to see if connection works
        fprintf(myRooms[counter], "CONNECTION 1: %s\n", structureRooms[counter].name);
        counter++;
    }
    return 0;
    }

Body:
In your call below, remove the "struct room".  You've already declared the type in the function declaration.

// Create all connections in the graph
while (IsGraphFull(structureRooms) == false)
{
    AddRandomConnection(struct room RoomA.outboundConnections, struct room RoomB.outboundConnections);
}

So that it is just AddRandommConnection(RoomA.outboundConnections, Roomb.outboundConnections);


问:
How to blur the BottomNavigationBar in Flutter?
I want to blur the background of BottomNavigationBar of a scaffold, so that it can give cool blur effect of items behind it. How can I do that?

More Info: I've tried adding opacity to canvasColor by creating a new theme to the BottomNaviagtionBar. This is my code:

bottomNavigationBar: new Theme(
    data: Theme.of(context).copyWith(
       canvasColor: Color(0xff424242).withOpacity(0.5),
    ),
    child: new BottomNavigationBar(
       onTap: navigationTapped,
       currentIndex: _page,
       items: [
          new BottomNavigationBarItem(
            icon: new Icon(Icons.home),
            title: new Text('Home')
          ),
          new BottomNavigationBarItem(
            icon: new Icon(Icons.dashboard),
            title: new Text('Menu')
          ),
          new BottomNavigationBarItem(
            icon: new Icon(Icons.date_range),
            title: new Text('Dates')
          )
        ],
    ),
  )

And this is output I'm getting:Image

Surprisingly, as you can see, the opacity is not at all applied. I actually don't want the BottomNavigationBar to be opaque. I want it to be blurred so that the content behind it can be viewed as blurred on the BottomNaviagtionBar. I've tried also to wrap BottomNavigationBar inside ImageFilter.blur(), But that also didn't work.

答:
For this to work I had to place the bottom navigation in a stack with the other content of the screen. I used combination of ClipRect, BackdropFilter and Opacity. This is the working solution: </p>

```<code> @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: _buildAppBar(context),
      body: Stack(
        //these are the screens that will be loaded for every bottom nav item
        children: <Widget>[
          IndexedStack(
            index: _currentTab,
            children: _pages,
          ),
          _buildBottomNavigation()
        ],
      ),
    );
  }

Widget _buildBottomNavigation() => Align(
        alignment: FractionalOffset.bottomCenter,
        //this is very important, without it the whole screen will be blurred
        child: ClipRect(
          //I'm using BackdropFilter for the blurring effect
          child: BackdropFilter(
            filter: ImageFilter.blur(
              sigmaX: 10.0,
              sigmaY: 10.0,
            ),
            child: Opacity(
              //you can change the opacity to whatever suits you best
              opacity: 0.8,
              child: BottomNavigationBar(
                currentIndex: _currentTab,
                onTap: (int index) {
                  setState(() {
                    _currentTab = index;
                  });
                },
                type: BottomNavigationBarType.fixed,
                unselectedItemColor: AppColors.colorBlack,
                items: allRoutes.map((NavigationRoute route) {
                  return _buildBottomNavigationBarItem(route);
                }).toList(),
              ),
            ),
          ),
        ),
      );
</code>```

Body:
For this to work I had to place the bottom navigation in a stack with the other content of the screen. I used combination of ClipRect, BackdropFilter and Opacity. This is the working solution:

 @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: _buildAppBar(context),
      body: Stack(
        //these are the screens that will be loaded for every bottom nav item
        children: <Widget>[
          IndexedStack(
            index: _currentTab,
            children: _pages,
          ),
          _buildBottomNavigation()
        ],
      ),
    );
  }

Widget _buildBottomNavigation() => Align(
        alignment: FractionalOffset.bottomCenter,
        //this is very important, without it the whole screen will be blurred
        child: ClipRect(
          //I'm using BackdropFilter for the blurring effect
          child: BackdropFilter(
            filter: ImageFilter.blur(
              sigmaX: 10.0,
              sigmaY: 10.0,
            ),
            child: Opacity(
              //you can change the opacity to whatever suits you best
              opacity: 0.8,
              child: BottomNavigationBar(
                currentIndex: _currentTab,
                onTap: (int index) {
                  setState(() {
                    _currentTab = index;
                  });
                },
                type: BottomNavigationBarType.fixed,
                unselectedItemColor: AppColors.colorBlack,
                items: allRoutes.map((NavigationRoute route) {
                  return _buildBottomNavigationBarItem(route);
                }).toList(),
              ),
            ),
          ),
        ),
      );


问:
Why is my ECS task public IP not loading, if the logs say the service has started?
I'm trying to deploy a super simple containerized flask app to ECS. I know the image is docker-compose-able and building fine because I have it as part of a CodePipeline that's building, tagging and pushing the final docker image to ECR.

```<code>Build completed on Sat Feb 15 21:48:44 UTC 2020

[Container] 2020/02/15 21:48:44 Running command echo Pushing the Docker images...
Pushing the Docker images...

[Container] 2020/02/15 21:48:44 Running command docker push $REPOSITORY_URI:latest
...
025f20c0831b: Pushed
98e916abdf11: Pushed
</code>```

I should probably clarify at this point that the application works locally, and I've specified the app.run() host to 0.0.0.0.

At this point I have an ECS Cluster

with a running task and public IP

and logs that indicate the app has started.

I have also modified the security group's inbound ports to include 5000 on 0.0.0.0, ::/0.

Theoretically this means you should be able to visit the port 3.80.1.115, but instead you should be seeing the standard, what did you just even type in response from your browser.

I'm just not sure what is happening anymore because I seem so close... the app is running without errors in ECS and everything is wonderful except the app is, well, inaccessible. Thoughts?

答:
Maybe you should review the networkMode and portMappings settings for your ECS task definition.

In the security group, you're allowing traffic for the port TCP/80, but what I can read at your application logs (Running on http://0.0.0.0:5000/) is that your app is running in a different port TCP/5000.

Here is an example for a Nginx task listening on por TCP/80:

```<code>{
  "requiresCompatibilities": [
    "FARGATE"
  ],
  "containerDefinitions": [
    {
      "name": "nginx",
      "image": "nginx:latest",
      "memory": 256,
      "cpu": 256,
      "essential": true,
      "portMappings": [
        {
          "containerPort": 80,
          "protocol": "tcp"
        }
      ],
      "logConfiguration":{
            "logDriver":"awslogs",
            "options":{
               "awslogs-group":"awslogs-nginx-ecs",
               "awslogs-region":"us-east-1",
               "awslogs-stream-prefix":"ecs"
            }
      }
    }
  ],
  "volumes": [],
  "networkMode": "awsvpc",
  "placementConstraints": [],
  "family": "nginx",
  "memory": "512",
  "cpu": "256"
}
</code>```

You can see other examples here

Body:
I'm trying to deploy a super simple containerized flask app to ECS. I know the image is docker-compose-able and building fine because I have it as part of a CodePipeline that's building, tagging and pushing the final docker image to ECR.

Build completed on Sat Feb 15 21:48:44 UTC 2020

[Container] 2020/02/15 21:48:44 Running command echo Pushing the Docker images...
Pushing the Docker images...

[Container] 2020/02/15 21:48:44 Running command docker push $REPOSITORY_URI:latest
...
025f20c0831b: Pushed
98e916abdf11: Pushed

I should probably clarify at this point that the application works locally, and I've specified the app.run() host to 0.0.0.0.

At this point I have an ECS Cluster

with a running task and public IP

and logs that indicate the app has started.

I have also modified the security group's inbound ports to include 5000 on 0.0.0.0, ::/0.

Theoretically this means you should be able to visit the port 3.80.1.115, but instead you should be seeing the standard, what did you just even type in response from your browser.

I'm just not sure what is happening anymore because I seem so close... the app is running without errors in ECS and everything is wonderful except the app is, well, inaccessible. Thoughts?

Body:
Maybe you should review the networkMode and portMappings settings for your ECS task definition.

In the security group, you're allowing traffic for the port TCP/80, but what I can read at your application logs (Running on http://0.0.0.0:5000/) is that your app is running in a different port TCP/5000.

Here is an example for a Nginx task listening on por TCP/80:

{
  "requiresCompatibilities": [
    "FARGATE"
  ],
  "containerDefinitions": [
    {
      "name": "nginx",
      "image": "nginx:latest",
      "memory": 256,
      "cpu": 256,
      "essential": true,
      "portMappings": [
        {
          "containerPort": 80,
          "protocol": "tcp"
        }
      ],
      "logConfiguration":{
            "logDriver":"awslogs",
            "options":{
               "awslogs-group":"awslogs-nginx-ecs",
               "awslogs-region":"us-east-1",
               "awslogs-stream-prefix":"ecs"
            }
      }
    }
  ],
  "volumes": [],
  "networkMode": "awsvpc",
  "placementConstraints": [],
  "family": "nginx",
  "memory": "512",
  "cpu": "256"
}

You can see other examples here


问:
AppWidgetManager.getInstalledProviders() doesn't return all installed widgets
I use the following code to return all available (installed) widgets. But it doesn't return all of them. In my case, it returns 47 widgets, while the stock launcher has 73 widgets.</p>

```<code>AppWidgetManager mAppWidgetManager = AppWidgetManager.getInstance(getApplicationContext());
List<AppWidgetProviderInfo> infoList = mAppWidgetManager.getInstalledProviders();

for (AppWidgetProviderInfo info : infoList) {

}
</code>```

答:
Thanks to @CommonsWare's assistance, these extras are not widgets, they are shortcuts to activities that are fetched using the following code.</p>

```<code>Intent shortcutsIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT);
List<ResolveInfo> shortcuts = getPackageManager().queryIntentActivities(shortcutsIntent, 0);
</code>```

Body:
I use the following code to return all available (installed) widgets. But it doesn't return all of them. In my case, it returns 47 widgets, while the stock launcher has 73 widgets.

AppWidgetManager mAppWidgetManager = AppWidgetManager.getInstance(getApplicationContext());
List<AppWidgetProviderInfo> infoList = mAppWidgetManager.getInstalledProviders();

for (AppWidgetProviderInfo info : infoList) {

}

Body:
Thanks to @CommonsWare's assistance, these extras are not widgets, they are shortcuts to activities that are fetched using the following code.

Intent shortcutsIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT);
List<ResolveInfo> shortcuts = getPackageManager().queryIntentActivities(shortcutsIntent, 0);