小编Dee*_*eep的帖子

Android:活动按钮显示在片段上

我有一个简单的应用程序,有一个 Activity 调用一个 Fragment。

我的问题是.. 为什么 Activity 的按钮显示在 Fragment 上?

似乎是一个非常简单的问题..只是无法确定问题所在!!

活动截图:

在此处输入图片说明

片段截图:

在此处输入图片说明

请注意,Activity 的 SUBMIT 按钮显示在 Fragment 上,但 TextView 和 EditText 被隐藏了。为什么 ??

活动 :

package com.example.deep_kulshreshtha.toddsyndrome;

import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.design.widget.TextInputEditText;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {

    private TextInputEditText inputEditText;
    private EditText editText;
    private ToddSyndromeDBHelper dbHelper;
    private SQLiteDatabase db;

    @Override
    protected void …
Run Code Online (Sandbox Code Playgroud)

android android-fragments android-activity

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

如何在CollapsingToolbarLayout中放置复杂的布局

我试图在CollapsingToolbarLayout中放置一个复杂的布局.附图描述了细节.

  • 我想要的 - 在我的CollapsingToolbarLayout中添加所描述的自定义布局.
  • 有什么问题
  • CirclePageIndicator不可见(截图如下)
  • ViewPager在ViewPager中滑动会显示空白屏幕.这是depite PagerAdapter配置.
  • 任何尝试将我的自定义布局带到CollapsingToolbarLayout外部并使其成为AppBarLayout的直接子项会带来一个空白屏幕.
  • 我做了什么 -
  • 尝试创建CollapsingToolbarLayout的子LinearLayout - 这不显示CirclePageIndicator并且不一致地显示ViewPager
  • 尝试创建一个AppBarLayout的子LinearLayout - 这显示一个空白屏幕.

我该如何解决这个问题?

任何帮助真的很感激!

所需的布局

activity_main.xml中

<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

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

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:contentScrim="@android:color/darker_gray"
            app:expandedTitleMarginStart="48dp"
            app:expandedTitleMarginEnd="64dp"
            android:fitsSystemWindows="true">

            <!--<ImageView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:src="@drawable/charts"
                android:scaleType="centerCrop"
                android:fitsSystemWindows="true"
                app:layout_collapseMode="parallax"
                app:layout_collapseParallaxMultiplier="0.1" />-->

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical"
                android:background="@drawable/charts" >

                <android.support.v4.view.ViewPager
                    android:id="@+id/pager"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" />

                <com.viewpagerindicator.CirclePageIndicator
                    android:id="@+id/circlePageInd"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content" />

            </LinearLayout>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                app:layout_collapseMode="pin"/>

        </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        app:layout_anchor="@id/appbar_layout" …
Run Code Online (Sandbox Code Playgroud)

android material-design android-collapsingtoolbarlayout

6
推荐指数
0
解决办法
1033
查看次数

AWS Lambda 控制台 - 升级 boto3 版本

我正在创建一个 DeepLens 项目来识别人,当相机扫描选定的一组人时。

该项目使用 lambda,它处理图像并触发“重新识别”aws api。

  • 当我从本地机器触发 API 时 - 我得到了很好的响应

  • 当我从 AWS 控制台触发 API 时 - 我收到失败的响应

问题

经过大量挖掘,我发现“boto3”(AWS python 库)的版本是:

  • 1.9.62 - 在我的本地机器上

  • 1.8.9 - 在 AWS 控制台上

我可以在 AWS lambda 控制台上升级“boto3”库版本吗??如果是这样,如何?

amazon-web-services boto3 aws-lambda amazon-rekognition

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

使用RemoteViews的通知不起作用

我正在尝试发出自定义通知(具有播放暂停,下一个和上一个按钮).但这似乎不起作用:

  • 我想要的:从我的活动中发出带有播放暂停,下一个和上一个按钮的自定义通知.此活动有一个有效的MediaPlayer

  • 问题是:通知根本没有发出.

  • 我做了什么:MediaPlayer完成后,从我的Activity onCreate()调用以下代码:

任何帮助都非常感谢.谢谢 !!

    private void sendNotification() {

        Log.v(LOGTAG, "Inside sendNotification");

        // Creating RemoteView and inflating it with a custom XML layout file    
        RemoteViews notificationViews = new RemoteViews(getPackageName(), R.layout.notification);

        Updating some fields in the layout file
        notificationViews.setTextViewText(R.id.songNameTextViewNotify, trackInfo.getTrack());
        notificationViews.setImageViewUri(R.id.songImageViewNotify, Uri.parse(trackInfo.getAlbumImageURL()));

        // Notification builder    
        NotificationCompat.Builder builder = new NotificationCompat.Builder(this).
                setContent(notificationViews);

                // Pending intent to call my class
                // The intent will be caught in the onNewIntent() method
        Intent intent = new Intent(this, MusicPlayer.class);
        PendingIntent pendingIntent …
Run Code Online (Sandbox Code Playgroud)

notifications android android-mediaplayer android-remoteview

5
推荐指数
0
解决办法
1556
查看次数

时间复杂度:得到不正确的结果

以下代码来自“破解编码面试”一书。该代码打印字符串的所有排列。

问题:下面代码的时间复杂度是多少。

void permutation(String str) {
    permutation(str, "");
}

private void permutation(String str, String prefix) {

    if (str.length() == 0){
        System.out.println(prefix);
    } else {
        for (int i = 0; i <str.length(); i++) {
            String rem = str.substring(0, i) + str.substring(i + 1);
            permutation(rem, prefix + str.charAt(i));
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我的理解:

我能够将时间复杂度推导出为:n * n!。

我确定我错过了蓝色、绿色和黄色节点的时间复杂度。但尽管反复尝试,始终没有明确能够找出出路。

有人可以分享一些输入,最好是例子吗?

在此处输入图片说明

java string big-o permutation time-complexity

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

将Stream分配给变量:可以吗?

如果我将流分配给变量,例如

final Stream<String> docs = REST_CLIENT.postLS(RestClient.appendSegmentToPath(bucketUrl, "_bulk_get"),
Run Code Online (Sandbox Code Playgroud)

这是个坏主意吗?因为流将需要将数据存储在内存中-就像Collection一样。但是与集合不同,流没有指定如何存储数据-作为数组,树或其他形式

java java-stream

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