在我正在使用的控制器中:
if ($validator->fails())
{
return Redirect::to('/admin/profile')
->withErrors($validator)
->withInput();
}
Run Code Online (Sandbox Code Playgroud)
如何在视图中获得withErrors的结果?
{{ $errors->all() }}
Run Code Online (Sandbox Code Playgroud) 在下面的示例代码中,我将如何调节Eloquent无法保存或更新字段或断开SQL连接等错误?
$user = new User;
$user->name = 'John';
$user->save();
Run Code Online (Sandbox Code Playgroud) 我写了简单的小部件作为textview与一些属性,我想在扩展的TextView类中设置字体,如何做这个动作,我可以有这种能力?
atributes:
<resources>
<declare-styleable name="TextViewStyle">
<attr name="selected_background" format="integer" />
<attr name="font" format="string" />
</declare-styleable>
</resources>
Run Code Online (Sandbox Code Playgroud)
自定义textview小部件:
public class TextViewStyle extends TextView{
public TextViewStyle(Context context) {
super(context);
}
public TextViewStyle(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public TextViewStyle(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TextViewStyle, defStyle, 0);
a.recycle();
}
}
Run Code Online (Sandbox Code Playgroud)
简单的UI小部件到xml:
<ir.jaziire.widgets.TextViewStyle
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/topic"
android:textColor="#000"
android:textSize="14dp"
android:gravity="right"
/>
Run Code Online (Sandbox Code Playgroud)
在这个小部件中,我想设置app:font=""为从资产设置任何字体
我更google搜索我怎样才能将简单view的对象传递给片段,但我不能.
例如在MainActivity中,我有一个简单的视图:
TextView text = (TextView) findviewById(R.id.tv_text);
Run Code Online (Sandbox Code Playgroud)
现在我想把它传递给片段.下面的代码是我在MainActivity上的附加片段
MainActivity :
public void attachFragment() {
fts = getActivity().getFragmentManager().beginTransaction();
mFragment = new FragmentMarketDetail();
fts.replace(R.id.cardsLine, mFragment, "FragmentMarketDetail");
fts.commit();
}
Run Code Online (Sandbox Code Playgroud)
这是我的Fragment:
public class FragmentMarketDetail extends Fragment implements ObservableScrollViewCallbacks {
public static final String SCROLLVIEW_STATE = "scrollviewState";
private ObservableScrollView scrollViewTest;
private Context context;
private int scrollY;
public static FragmentMarketDetail newInstance() {
FragmentMarketDetail fragmentFirst = new FragmentMarketDetail();
return fragmentFirst;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater …Run Code Online (Sandbox Code Playgroud) 在我的数据库中,我有instagram_actions_histories一个表,其中有action_type一个列,在该列中我有不同的数据,例如1或2或3
例如,我正在尝试获取此表数据的关系并对存储在列中的值求和
$userAddedPagesList = auth()->user()->instagramPages()->with([
'history' => function ($query) {
$query->select(['action_type as count'])->whereActionType(1)->sum('action_type');
}
]
)->get();
Run Code Online (Sandbox Code Playgroud)
顺便说一句,这段代码不正确,因为我想获得其中history包含多个的所有内容sum
whereActionType(1)->sum('action_type')
whereActionType(2)->sum('action_type')
whereActionType(3)->sum('action_type')
Run Code Online (Sandbox Code Playgroud)
例如(伪代码):
$userAddedPagesList = auth()->user()->instagramPages()->with([
'history' => function ($query) {
$query->select(['action_type as like'])->whereActionType(1)->sum('action_type');
$query->select(['action_type as follow'])->whereActionType(2)->sum('action_type');
$query->select(['action_type as unfollow'])->whereActionType(3)->sum('action_type');
}
]
)->get();
Run Code Online (Sandbox Code Playgroud)
更新:
$userAddedPagesList = auth()->user()->instagramPages()->with([
'history' => function ($query) {
$query->select('*')
->selectSub(function ($query) {
return $query->selectRaw('SUM(action_type)')
->where('action_type', '=', '1');
}, 'like')
->selectSub(function ($query) {
return $query->selectRaw('SUM(action_type)')
->where('action_type', …Run Code Online (Sandbox Code Playgroud) 我得到java.lang.module.FindException: Module java.se.ee not found的错误,当我尝试更新Android SDK中我把这个路径/etc/environment:
JAVA_HOME="/usr/lib/jvm/java-12-oracle"
export JAVA_HOME
export JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'
export SDKMANAGER_OPTS='--add-modules java.se.ee'
Run Code Online (Sandbox Code Playgroud)
并在运行此命令后:
source /etc/environment
Run Code Online (Sandbox Code Playgroud)
我在终端上没有收到任何消息,现在这个命令:
sudo /usr/lib/android-sdk/tools/bin/sdkmanager --update
Run Code Online (Sandbox Code Playgroud)
告诉我这个错误:
Error occurred during initialization of boot layer
java.lang.module.FindException: Module java.se.ee not found
Run Code Online (Sandbox Code Playgroud)
更新:
我安装 OpenJDK
$ java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-8u212-b01-1-b01)
OpenJDK 64-Bit Server VM (build 25.212-b01, mixed mode)
Run Code Online (Sandbox Code Playgroud)
设置为默认值后,我也收到错误
错误:无法找到或加载主类 java.se.ee
重新启动 ubuntu - 终端和source /etc/environment命令无法解决我的问题
DEFAULT_JVM_OPTS 关于 sdkmanager 文件内容:
#DEFAULT_JVM_OPTS='"-Dcom.android.sdklib.toolsdir=$APP_HOME"'
Run Code Online (Sandbox Code Playgroud) 在此示例代码中,当我尝试缩放图标时,我想将图标大小限制ScaleTransition为 10% ,但我无法这样做来对图标进行此限制zoom-inzoom-out
import 'package:flutter/material.dart';
import 'package:flutter/animation.dart';
void main() => runApp(MyApp());
class ScaleTransitionExample extends StatefulWidget {
_ScaleTransitionExampleState createState() => _ScaleTransitionExampleState();
}
class _ScaleTransitionExampleState extends State<ScaleTransitionExample> with TickerProviderStateMixin {
AnimationController _controller;
Animation<double> _animation;
initState() {
super.initState();
_controller = AnimationController(duration: const Duration(milliseconds: 2000), vsync: this);
_animation = CurvedAnimation(parent: _controller, curve: Curves.ease);
_controller.forward();
}
@override
dispose() {
_controller.dispose();
super.dispose();
}
Widget build(BuildContext context) {
return Container(
color: Colors.white,
child: Stack(
children: <Widget>[
Center(
child: ScaleTransition(
scale: _animation,
alignment: Alignment.center, …Run Code Online (Sandbox Code Playgroud) 假设我有这门课:
class AppTheme {
final BuildContext context;
AppTheme(this.context);
TextStyle caption() {
return Theme.of(context).textTheme.caption.copyWith(
color: Colors.black
);
}
}
Run Code Online (Sandbox Code Playgroud)
如何以可以使用以下方式访问的方式修改它caption:
AppTheme.of(context).caption();
Run Code Online (Sandbox Code Playgroud)