小编Koe*_*ren的帖子

C#变量无法更改但需要在构造函数中初始化

我需要一个在构造函数初始化后无法更改的属性

这样的事:

private const string banknr;

public ClassName(string banknr)
{
    this.banknr = banknr;
    //from now on "banknr" can't be changed something like a final or const
}
Run Code Online (Sandbox Code Playgroud)

但它只是不起作用,我真的不明白

c# constructor final const

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

无法让操作栏中的 SearchView 工作

我已经尝试了很多教程、stackoverflow 解决方案和 google 教程 -> https://www.youtube.com/watch?v=9OWmnYPX1uc但我无法让操作栏中的搜索视图工作。

有没有人看到我做错了什么?

我总是在 searchView 上得到一个空指针异常

我的列表视图活动:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.list_menu, menu);
    MenuItem searchItem = menu.findItem(R.id.action_search);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setOnQueryTextListener(
            new SearchView.OnQueryTextListener() {
                @Override
                public boolean onQueryTextSubmit(String query) {
                    Toast.makeText(ContactListActivity.this, query, Toast.LENGTH_SHORT).show();
                    return false;
                }

                @Override
                public boolean onQueryTextChange(String newText) {
                    Toast.makeText(ContactListActivity.this, newText, Toast.LENGTH_SHORT).show();
                    return false;
                }
            }
    );

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    ComponentName …
Run Code Online (Sandbox Code Playgroud)

search android listview list searchview

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

以编程方式在分屏中打开应用程序

如何在 android N (SDK 24) 中分屏打开另一个应用程序?

在文档中我发现了这一点:


以多窗口模式启动新活动

当您启动一项新活动时,您可以提示系统新活动应显示在当前活动旁边(如果可能)。为此,请使用标志 Intent.FLAG_ACTIVITY_LAUNCH_TO_ADJACENT。传递此标志请求以下行为:

如果设备处于分屏模式,系统会尝试在启动它的 Activity 旁边创建新 Activity,以便这两个 Activity 共享屏幕。系统不保证能够做到这一点,但如果可能的话,它会使活动相邻。如果设备未处于分屏模式,则此标志无效。如果设备处于自由格式模式并且您要启动新活动,则可以通过调用 ActivityOptions.setLaunchBounds() 指定新活动的尺寸和屏幕位置。如果设备不处于多窗口模式,则此方法无效。


所以当我尝试这个时,该Intent.FLAG_ACTIVITY_LAUNCH_TO_ADJACENT标志不存在。我安装了

  • Android 6.x (N) SDK 24 修订版 1
  • Android N 预览版 SDK N 修订版 3
  • Android 6.0(棉花糖)SDK 23 修订版 3

这是我的等级:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.0"

    defaultConfig {
        applicationId "PACKAGENAME"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 2
        versionName "2.4.1"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], …
Run Code Online (Sandbox Code Playgroud)

java android android-intent split-screen-multitasking android-7.0-nougat

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

Disable Flutter text Baseline

How can I disable the textbaseline?

在此处输入图片说明

because my text is not centered

在此处输入图片说明

I try to center a text in a contair. I use this font: https://www.dafont.com/young.font?l[]=10&l[]=1

import 'package:flutte_template/styles/theme_dimens.dart';
import 'package:flutter/material.dart';

class RoundedChip extends StatelessWidget {
  final Widget child;
  final Color color;

  const RoundedChip({@required this.child, @required this.color});

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Padding(
        padding: const EdgeInsets.symmetric(horizontal: 12, vertical: ThemeDimens.padding4),
        child: Row(
          mainAxisSize: MainAxisSize.min,
          children: [
            Padding(
             padding: const EdgeInsets.symmetric(vertical: ThemeDimens.padding4),
             child: Text('Drama', style: ThemeTextStyles.mediaDetailGenreText),
            ),
          ],
        ),
      ), …
Run Code Online (Sandbox Code Playgroud)

fonts flutter flutter-layout

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

Flutter CustomScrollView 在没有足够的项目时滚动

使用 slivers 和 sliver appbar 时出现滚动问题。当视频中不需要滚动时,如何防止滚动视图滚动。如果有足够的滚动项,它应该滚动(这很好用)

我关注了这个中等帖子。你可以看到他有同样的问题。 https://medium.com/@diegoveloper/flutter-collapsing-toolbar-sliver-app-bar-14b858e87abe

https://youtu.be/l1EwM9GAfxw

class HomeScreen extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: NestedScrollView(
        headerSliverBuilder: (context, innerBoxIsScrolled) => [
          SliverAppBar(
            brightness: Brightness.dark,
            backgroundColor: Colors.amber.withOpacity(0.5),
            expandedHeight: 166,
            flexibleSpace: FlexibleSpaceBar(
              collapseMode: CollapseMode.pin,
              background: SafeArea(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Container(
                      height: 80,
                      width: 80,
                      child: Placeholder(),
                    ),
                    Row(
                      children: [
                        Text(
                          'sdalkf',
                        ),
                      ],
                    ),
                  ],
                ),
              ),
            ),
          ),
          SliverPersistentHeader(
            delegate: SliverAppBarDelegate(
              MediaQuery.of(context).padding.top,
              Container(
                color: Colors.amber.withOpacity(0.5),
                child: SafeArea(
                  bottom: false,
                  child: Column( …
Run Code Online (Sandbox Code Playgroud)

flutter flutter-sliver flutter-layout

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

写"?" 如果属性为null,则为字符串

我怎么能像"?"一样写Startted 是Startdate是null

public DateTime? StartDate { get; set; }

public override string ToString()
{
    return String.Format("Course {0} ({1} is an {2} course, will be given by {3}, starts on {4}, costs {5:0.00} and will have maximum {6} participants"
        , Name
        , CourseId
        , CourseType
        , Teacher
        , (StartDate == null ? "?" : StartDate)
        , Price
        , MaximumParticipants);
}
Run Code Online (Sandbox Code Playgroud)

c# datetime tostring string-formatting

3
推荐指数
2
解决办法
121
查看次数

Arcore 片段在启动时崩溃

刚开始使用 ARCore。我想在飞机上显示一个简单的 3d 模型。我使用的是 ARCore 1.10.0 版。当我启动应用程序时,应用程序崩溃并显示以下堆栈跟踪:

这是我的布局

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <fragment
        android:id="@+id/ar_fragment"
        android:name="com.google.ar.sceneform.ux.ArFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <include
        android:id="@+id/overlay"
        layout="@layout/overlay"
        app:showOverlay="@{showOverlay}" />

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

我使用数据绑定来扩充布局。我不知道我做错了什么。看起来无法找到 ArFragment。

2019-07-23 14:05:15.209 12108-12108/com.icapps.arcapps E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.icapps.arcapps, PID: 12108
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.icapps.arcapps/com.icapps.arcapps.activity.products.PlantDetailActivity}: android.view.InflateException: Binary XML file line #23: Binary XML file line #23: Error inflating class fragment
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3037)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3172)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1906)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6863)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537) …
Run Code Online (Sandbox Code Playgroud)

android kotlin arcore

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

在 Flutter 中绘制列表视图边界之外

我想改变我的项目,它比列表视图本身更大。(集中导航的意图)

我的列表:

        Container(
          height: 100,
          child: ListView.builder(
            itemBuilder: (context, index) => HomeItem(title: '$index'),
            scrollDirection: Axis.horizontal,
          ),
        ),
Run Code Online (Sandbox Code Playgroud)

我的物品:

class HomeItem extends StatelessWidget {
  final String title;
  final bool expand;

  const HomeItem({
    @required this.title,
    this.expand = false,
  });

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.symmetric(horizontal: ThemeDimens.padding8),
      child: Transform.scale(
        scale: expand ? 1.5 : 1,
        child: AnimatedContainer(
          width: 50,
          height: 100,
          color: expand ? ThemeColors.accent : ThemeColors.primary,
          duration: ThemeDurations.shortAnimationDuration(),
          child: Center(
            child: Text(title),
          ),
        ),
      ),
    );
  }
} …
Run Code Online (Sandbox Code Playgroud)

flutter flutter-layout flutter-animation flutter-listview

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