小编Dol*_*rma的帖子

PHP $ this不在对象上下文中来自类外的set public变量

我有简单的类,我想public从课外设置变量.

<?php

class AlachiqHelpers
{
    public $height;

    public static function getHeight($height)
    {
        return $this->height - 50;
    }

    public static function setHeight($height)
    {
        $this->height = $height;
    }
}
Run Code Online (Sandbox Code Playgroud)

在结果中我收到此错误:

Using $this when not in object context
Run Code Online (Sandbox Code Playgroud)

php arrays oop static function

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

Android如何通过xml或programical绘制正多边形

有没有办法在Android xml布局上绘制多边形?

在此输入图像描述

或者是任何帮助类作为库来绘制它们?

android polygon android-layout

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

Android将Cardview置于RelativeLayout的父级Cardview顶部

如何在屏幕截图下放置cardview父母cardview

在此输入图像描述

当我把图像放到CardView破坏我的视线的原因

正确的观点必须是:

在此输入图像描述

我的xml布局:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/content_background">

    <android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <android.support.design.widget.AppBarLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <android.support.v7.widget.Toolbar
                    android:id="@+id/activity_main_toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="65dp"
                    android:background="@color/colorPrimary"
                    android:titleTextColor="#ffffff">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:orientation="horizontal">

                        <com.joanzapata.iconify.widget.IconTextView
                            android:id="@+id/icon_signal_robot"
                            android:layout_width="wrap_content"
                            android:layout_height="match_parent"
                            android:layout_marginRight="10dp"
                            android:clickable="true"
                            android:gravity="center|right"
                            android:shadowColor="#22000000"
                            android:shadowDx="3"
                            android:shadowDy="3"
                            android:shadowRadius="1"
                            android:text="{fa-android}"
                            android:textColor="@color/quote"
                            android:textSize="30sp"/>

                        <com.joanzapata.iconify.widget.IconTextView
                            android:id="@+id/icon_search_icon"
                            android:layout_width="wrap_content"
                            android:layout_height="match_parent"
                            android:layout_marginRight="10dp"
                            android:clickable="true"
                            android:gravity="center|right"
                            android:shadowColor="#22000000"
                            android:shadowDx="3"
                            android:shadowDy="3"
                            android:shadowRadius="1"
                            android:text="{fa-search}"
                            android:textColor="#ffffff"
                            android:textSize="25sp"/>

                        <com.gigamole.library.ntb.NavigationTabBar
                            android:id="@+id/market_detail_navigation_tab_bar"
                            android:layout_width="90dp"
                            android:layout_height="30dp"
                            android:layout_gravity="center_vertical|left"
                            android:background="@drawable/bg_round_circle"
                            app:ntb_active_color="#4527A0"
                            app:ntb_animation_duration="150"
                            app:ntb_corners_radius="50dp"
                            app:ntb_inactive_color="#dddfec"
                            app:ntb_preview_colors="@array/red_wine"/>

                        <TextView …
Run Code Online (Sandbox Code Playgroud)

android relativelayout android-cardview

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

Android在recyclerview项目上实施facebook Rebound

我正在尝试ReboundRecyclerView项目上实现facebook ,但在我的解决方案之后,最后一项有动画,而不是所有项目,事实上其中一项是RecyclerView在触摸每个项目后工作的

扩展的SimpleSpringListener:

public class ExampleSpringListener extends SimpleSpringListener {
    private View sView;

    public void setsView(View v) {
        this.sView = v;
    }

    @Override
    public void onSpringUpdate(Spring spring) {
        float mappedValue = (float) SpringUtil.mapValueFromRangeToRange(spring.getCurrentValue(), 0, 1, 1, 0.5);
        sView.setScaleX(mappedValue);
        sView.setScaleY(mappedValue);
    }
}
Run Code Online (Sandbox Code Playgroud)

我的适配器:

@Override
public void onBindViewHolder(final MarketListsViewHolder holder, final int position) {
    mSpringListener.setsView(holder.market_lists_root);
    holder.market_lists_root.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    // When pressed start solving the …
Run Code Online (Sandbox Code Playgroud)

android facebook

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

在方向更改时更改 RecyclerView 的布局仅适用于第一个视图

在我的应用程序中,我有这个代码来计算手机尺寸并将RecyclerView布局管理器更改为GridLayoutManagerLinearLayoutManager

private void changeFeedsLayout() {
    // Choose between one, two or three elements per row
    if (dpWidth > 720 && getResources().getConfiguration().orientation ==
            ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
        instagram_feeds.setLayoutManager(new GridLayoutManager(
                context, 3, LinearLayoutManager.VERTICAL, false));
    } else if (dpWidth > 520) {
        instagram_feeds.setLayoutManager(new GridLayoutManager(
                context, 2, LinearLayoutManager.VERTICAL, false));
    } else {
        instagram_feeds.setLayoutManager(new LinearLayoutManager(
                context, LinearLayoutManager.VERTICAL, false));
    }
}
Run Code Online (Sandbox Code Playgroud)

当我将每个片段附加或提交到容器时,此代码工作正常MainActivity,但在更改手机方向时它不起作用,为了解决此问题,我使用此代码:

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    changeFeedsLayout();
}
Run Code Online (Sandbox Code Playgroud)

不幸的是,layoutmanagerRecyclerView总是LinearLayoutManager这样,我无法解决这个问题。打开其他片段并返回到上一个片段后工作正常。

更新

在更改手机方向时,此代码为:

instagram_feeds.setLayoutManager(new LinearLayoutManager(
                    context, …
Run Code Online (Sandbox Code Playgroud)

android android-fragments android-recyclerview

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

通过支持回到先前的片段,在片段之间颤动切换

在SF 中的此链接中,@ martinseal1987向我们展示了如何使用带有Android片段的分离的小部件链接。

我在项目上实现了此解决方案,并且在运行项目后,我没有任何问题可以将第一个小部件显示为Fragment,但是当我按下“后退”按钮时,我的屏幕变为黑色,并且无法返回到以前的小部件

我认为应该是这样的:

在此处输入图片说明

问题已经解决navigateBackcustomPop方法可以按下按钮来附加片段

import 'package:flutter/material.dart';

void main()
{
  runApp(MaterialApp(
    title: 'AndroidMonks',
    home: Scaffold(
      appBar: AppBar(
        title: Text('Androidmonks'),
        backgroundColor: Colors.orangeAccent,
      ),
      body: Home(),
    ),
  ));
}

class Home extends StatefulWidget {
  Home({
    Key key,
  }) : super(key: key);

  @override
  State<Home> createState()=>_Home();
}

class _Home extends State<Home> {
  String title = "Title";
  int _currentIndex = 0;
  final List<int> _backstack = [0];

  @override
  Widget build(BuildContext context) {
    navigateTo(_currentIndex);
    //each …
Run Code Online (Sandbox Code Playgroud)

flutter flutter-layout

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

Flutter 从类外管理动画控制器

这是我在课堂上使用的简单动画

controller = AnimationController(vsync: this, duration: Duration(milliseconds: 200));

offset = Tween<Offset>(begin: Offset.zero, end: Offset(0.0, -1.0)).animate(controller);
controller.forward();
Run Code Online (Sandbox Code Playgroud)

因为我只能管理动画控制器,例如forwardreverse类内部,我尝试将此控制器移动到类外部,就像另一个类一样NotificationBarController,有人可以帮助我如何实现此解决方案吗?

例如

controller = NotificationBarController();
controller.forward();
Run Code Online (Sandbox Code Playgroud)

源代码

class NotificationBar extends StatefulWidget {
  final Widget contentWidget;
  final Widget barWidget;

  NotificationBar({@required this.contentWidget, @required this.barWidget});

  @override
  State<StatefulWidget> createState() => NotificationBarState();
}

class NotificationBarState extends State<NotificationBar>  with SingleTickerProviderStateMixin {
  AnimationController controller;
  Animation<Offset> offset;

  @override
  void initState() {
    super.initState();

    controller = AnimationController(vsync: this, duration: Duration(milliseconds: 200));
    // offset = Tween<Offset>(begin: Offset.zero, end: Offset(1.0, …
Run Code Online (Sandbox Code Playgroud)

flutter flutter-animation

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

Flutter 使用弹性动画折叠和展开小部件

在这个简单的下面 ui 中,我拥有Container屏幕的权利,我想用elastic动画折叠和展开它,例如展开elasticIn动画和折叠elasticOut

在此处输入图片说明

flutter flutter-animation

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

Dart 使用 setter 进行从概念上更改属性的操作

在下面的代码中,当我尝试设置值时,ValueNotifier我得到了分析信息,

info: Use a setter for operations that conceptually change a property. (use_setters_to_change_properties at 
[XXXXX] lib\service\providers\value_notifier_scroll_to_selected_page_position.dart:6) 
Run Code Online (Sandbox Code Playgroud)

我的代码:

class ScrollToSelectedPagePosition {
  final ValueNotifier<int> position = ValueNotifier<int>(0);

  void scrollToPosition(int selectedPagePosition){
    position.value = selectedPagePosition; // <--- Getting info here
  }
}
Run Code Online (Sandbox Code Playgroud)

我如何为此定义设置器?

analytics dart flutter

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

Flutter 使用 RiverPod 状态管理更改文本值

在下面的代码中,我简单地编写了代码来更改Text小部件字符串,默认字符串可以显示在Text小部件中,但当我尝试单击时FloatingActionButton,它不会改变。

单击HotReload“原因”将其更改为新值,我应该在哪里更改以解决此问题?

import 'package:flutter/material.dart';
import 'package:hooks_riverpod/all.dart';


class MyString extends StateNotifier<String> {
  MyString() : super('Hello World');

  void change(String text) => state = text;
}

final showHello = StateNotifierProvider<MyString>((ref) => MyString());

void main() {
  runApp(ProviderScope(child: MyApp()));
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: Text('SAMPLE'),
        ),
        body: Center(
          child: Consumer(
            builder: (context, watch, _) …
Run Code Online (Sandbox Code Playgroud)

flutter riverpod

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