对于换行n在JButton.setText感兴趣的读者,本文将提供您所需要的所有信息,我们将详细讲解“fnordnfoo”中不起作用;,并且为您提供关于(15)各种Button与排列OutlineBu
对于换行 n在JButton.setText感兴趣的读者,本文将提供您所需要的所有信息,我们将详细讲解“ fnord nfoo”中不起作用;,并且为您提供关于(15)各种Button 与排列 OutlineButton,ButtonBar,Expanded,RaisedButton,StadiumBorder,FlatButton.icon、.net表单验证 – 手动设置HttpContext.Current.User在自定义AuthorizeAttribute中不起作用、android – EditText setError在PopupWindow中不起作用、android – 使用AppCompat.EditText设置AutoCompleteTextView样式不起作用的宝贵知识。
本文目录一览:- 换行 n在JButton.setText(“ fnord nfoo”)中不起作用;(\n换行不起作用)
- (15)各种Button 与排列 OutlineButton,ButtonBar,Expanded,RaisedButton,StadiumBorder,FlatButton.icon
- .net表单验证 – 手动设置HttpContext.Current.User在自定义AuthorizeAttribute中不起作用
- android – EditText setError在PopupWindow中不起作用
- android – 使用AppCompat.EditText设置AutoCompleteTextView样式不起作用
换行 n在JButton.setText(“ fnord nfoo”)中不起作用;(\n换行不起作用)
在JButton上,我想在多行上列出信息。我尝试\n
作为换行符,但是没有用。如下代码:
JButton.setText("fnord\nfoo") ;
将显示为:
fnordfoo
如何强制换行?
答案1
小编典典JButton接受HTML,因此为了使换行起作用,请使用:
JButton.setText("<html>fnord<br />foo</html>");
(15)各种Button 与排列 OutlineButton,ButtonBar,Expanded,RaisedButton,StadiumBorder,FlatButton.icon
效果
至于倒数第二行和倒数第一行的效果为啥一样。。可能是fluttersdk升级了。。之前的api不再生效。。算是留坑!
代码
import ''package:flutter/material.dart'';
class ButtonDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
final Widget _floatButtonDemo =
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
FlatButton(
onPressed: () {},
child: Text("FlatButton"),
splashColor: Colors.grey,
textColor: Theme.of(context).accentColor,
color: Colors.black87,
),
FlatButton.icon(
icon: Icon(Icons.add),
onPressed: () {},
label: Text("FlatButton.icon"),
splashColor: Colors.grey,
textColor: Theme.of(context).accentColor,
color: Colors.black87,
)
]);
final Widget _raisedButtonDemo =
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
Theme(
// data: ThemeData(),
data: Theme.of(context).copyWith(
buttonColor: Theme.of(context).accentColor,
buttonTheme: ButtonThemeData(
textTheme: ButtonTextTheme.primary,
// shape: BeveledRectangleBorder(borderRadius: BorderRadius.circular(5.0)),
shape: StadiumBorder(),
)),
child: RaisedButton(
onPressed: () {},
child: Text("RaisedButton"),
splashColor: Colors.grey,
textColor: Theme.of(context).accentColor,
// color: Colors.white,
// textTheme: ButtonTextTheme.primary,
elevation: 0.0,
)),
SizedBox(
width: 16.0,
),
RaisedButton.icon(
icon: Icon(Icons.add),
onPressed: () {},
label: Text("RaisedButton.icon"),
splashColor: Colors.grey,
textColor: Theme.of(context).accentColor,
elevation: 12.0,
)
]);
final Widget _outerLineButtonDemo =
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
Theme(
// data: ThemeData(),
data: Theme.of(context).copyWith(
buttonColor: Theme.of(context).accentColor,
buttonTheme: ButtonThemeData(
textTheme: ButtonTextTheme.primary,
// shape: BeveledRectangleBorder(borderRadius: BorderRadius.circular(5.0)),
shape: StadiumBorder(),
)),
child: OutlineButton(
onPressed: () {},
child: Text("OutlineButton"),
splashColor: Colors.grey[100],
textColor: Colors.black,
borderSide: BorderSide(color: Colors.black),
highlightedBorderColor: Colors.grey,
// textTheme: ButtonTextTheme.primary,
)),
SizedBox(
width: 16.0,
),
OutlineButton.icon(
icon: Icon(Icons.add),
onPressed: () {},
label: Text("OutlineButton.icon"),
splashColor: Colors.grey,
textColor: Theme.of(context).accentColor,
)
]);
final Widget _widthOuterLineButton = Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 200,
child: OutlineButton(
onPressed: () {},
child: Text("_widthOuterLineButton"),
splashColor: Colors.grey,
textColor: Colors.blue,
),
)
],
);
final Widget _expendOuterLineButton = Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: OutlineButton(
onPressed: () {},
child: Text("_expendOuterLineButton"),
splashColor: Colors.grey,
textColor: Colors.blue,
),
)
],
);
final Widget _expend2OuterLineButton = Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
flex: 1,
child: OutlineButton(
onPressed: () {},
child: Text("权重 for 1"),
splashColor: Colors.grey,
textColor: Colors.blue,
),
),
SizedBox(
width: 15,
),
Expanded(
//权重属性
flex: 2,
child: OutlineButton(
onPressed: () {},
child: Text("权重 for 2"),
splashColor: Colors.grey,
textColor: Colors.blue,
),
)
],
);
//一行并列行显示的按钮
final Widget _buttonBar = Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ButtonBar(
children: [
OutlineButton(
onPressed: () {},
child: Text("ButtonBar"),
splashColor: Colors.grey,
textColor: Colors.blue,
),
OutlineButton(
onPressed: () {},
child: Text("ButtonBar"),
splashColor: Colors.grey,
textColor: Colors.blue,
),
],
)
],
);
//对刚才的并排中间添加边距
final Widget _buttonBarPaddingv = Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Theme(
data: Theme.of(context).copyWith(
buttonTheme: ButtonThemeData(
padding: EdgeInsets.symmetric(horizontal: 100.0))),
child: ButtonBar(
children: [
OutlineButton(
onPressed: () {},
child: Text("ButtonBar"),
splashColor: Colors.grey,
textColor: Colors.blue,
),
OutlineButton(
onPressed: () {},
child: Text("ButtonBar"),
splashColor: Colors.grey,
textColor: Colors.blue,
),
],
),
)
],
);
return Scaffold(
appBar: AppBar(
title: Text("button Demo"),
elevation: 0.0,
),
body: Container(
padding: EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
_floatButtonDemo,
_raisedButtonDemo,
_outerLineButtonDemo,
_widthOuterLineButton,
_expendOuterLineButton,
_expend2OuterLineButton,
_buttonBar,
_buttonBarPaddingv
],
),
),
);
}
}
.net表单验证 – 手动设置HttpContext.Current.User在自定义AuthorizeAttribute中不起作用
setting HttpContext.Current.User
这似乎有效,直到我尝试使用自定义AuthorizeAttribute查看任何其他控制器方法.
控制器方式:
[HttpPost] [AllowAnonymous] public ActionResult Login(string username) { string password = ConfigurationManager.AppSettings["Pass"]; User user = service.Login(username,password); var name = FormsAuthentication.FormsCookieName; var cookie = Response.Cookies[name]; if (cookie != null) { var ticket = FormsAuthentication.Decrypt(cookie.Value); if (ticket != null && !ticket.Expired) { string[] roles = (ticket.UserData as string ?? "").Split(','); System.Web.HttpContext.Current.User = new GenericPrincipal(new FormsIdentity(ticket),roles); } } //...processing result return Json(result); }
上面的service.Login方法创建了cookie:
FormsAuthentication.SetAuthCookie(cookieValue,false);
虽然我设置了具有Identity和IsAuthenticated的用户,但下面的filterContext.HttpContext.User不是同一个用户.它基本上是空的,好像它从未被分配,并且没有被认证.
public override void OnAuthorization(AuthorizationContext filterContext) { string[] userDetails = filterContext.HttpContext.User.Identity.Name.Split(char.Parse("|")); }
我找到的最近的帖子是:IsAuthenticated works on browser – but not with Air client!
但是,针对我的修复已经到位了:
<authentication mode="Forms"> <forms cookieless="UseCookies" timeout="60" loginUrl="~/Account/Login" /> </authentication>
我使我的AuthorizationContext.User与我在控制器中验证的HttpContext.Current.User相匹配?
更新:
我意识到我需要一个重定向来正确设置cookie,我只是不能通过ajax调用远程完成该工作.在站点B上执行控制器方法时,站点A中的脚本是什么样的.此重定向不会设置会话.在下一个控制器方法上验证用户时仍然不存在.它只是将我重定向到登录视图.
function remoteLogin(id) { $.ajax({ url: "/MyController/RemoteLogin",type: "POST",dataType: "json",data: { "id": id } }).done(function (data) { if (data) { if (data.user) { var user = data.user; $.ajax({ url: "http://siteB.xyz/Account/Login",data: { "username": user.username,"password": user.password } }).done(function (data) { if (data) { window.location.href = "http://siteB.xyz/Next" } else { alert("Fail."); } }).fail(function (data) { alert("Fail."); }); } else { alert("Fail."); } } }).fail(function (data) { alert("Fail."); }); }
解决方法
Cookie只有在请求完成后才能在浏览器中设置.
android – EditText setError在PopupWindow中不起作用
android.view.WindowManager$BadTokenException: Unable to add window -- token android.view.ViewRootImpl$W@211ffd68 is not valid; is your activity running? at android.view.ViewRootImpl.setView(ViewRootImpl.java:579) at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:282) at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:85) at android.widget.PopupWindow.invokePopup(PopupWindow.java:1104) at android.widget.PopupWindow.showAsDropDown(PopupWindow.java:1008) at android.widget.PopupWindow.showAsDropDown(PopupWindow.java:968) at android.widget.Editor.showError(Editor.java:334) at android.widget.Editor.setError(Editor.java:355) at android.widget.TextView.setError(TextView.java:4654) at android.widget.TextView.setError(TextView.java:4639) at com.ebusiness.worldofjobs.helpers.HelperEditText.isEmailValid(HelperEditText.java:38) at com.ebusiness.worldofjobs.activities.LoginActivity$4$2.onClick(LoginActivity.java:149) at android.view.View.performClick(View.java:4785) at android.view.View$PerformClick.run(View.java:19884) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5343) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
弹出窗口:
View popupView = LayoutInflater.from(LoginActivity.this).inflate(R.layout.popup_reset_password,null); EdiText etSmaple = (EditText) popupView.findViewById(R.id.etSmample); Button buttonSample = (Button) popupView.findViewById(R.id.buttonSample); final PopupWindow popupWindow = new PopupWindow(popupView,600,400); popupWindow.setFocusable(true); buttonSample.setonClickListener(new OnClickListener() { @Override public void onClick(View v) { // Here''s the exception raising etSample.setError("nothing..."); } }); popupWindow.showAtLocation(popupView,Gravity.CENTER,0);
解决方法
Reference
android – 使用AppCompat.EditText设置AutoCompleteTextView样式不起作用
我想更改AutoCompleteTextView样式
像android.support.v7.internal.widget.TintEditText中的样式
我在style.xml中添加了样式:
<style name="AppTheme" parent="AppTheme.Base"/> <style name="AppTheme.Base" parent="Theme.AppCompat"> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="android:autoCompleteTextViewStyle">@style/AutoCompleteTextViewAppTheme</item> </style> <style name="AutoCompleteTextViewAppTheme" parent="Base.Widget.AppCompat.EditText"/>
这有效,但线条颜色不会改变.
具有材质设计的EditTexts似乎使用colorControlActivated和colorControlnormal.因此,我试图在先前的样式定义中覆盖这些属性,但它没有任何效果.
我需要做什么才能让它发挥作用?
解决方法
<View... />
如果这不起作用,你可以尝试自己设计.
您必须更改可以查找的TextView属性here.
可以通过更改应添加到样式中的android:textColor属性来更改实例的Textcolor,例如:
<style name="AutoCompleteTextViewAppTheme" parent="Base.Widget.AppCompat.EditText"/> <item name="android:textColor">#ffffffff</item> </style>
如果要更改edittext行,则必须更改背景属性,例如以这种方式:
<item name ="android:background="@drawable/line_background"> </item>
并在drawables文件夹中添加一个具有类似内容的新文件line_background.xml:
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line"> <stroke android:color="#c0c000" android:width="3dp"></stroke> </shape>
关于换行 n在JButton.setText和“ fnord nfoo”中不起作用;的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于(15)各种Button 与排列 OutlineButton,ButtonBar,Expanded,RaisedButton,StadiumBorder,FlatButton.icon、.net表单验证 – 手动设置HttpContext.Current.User在自定义AuthorizeAttribute中不起作用、android – EditText setError在PopupWindow中不起作用、android – 使用AppCompat.EditText设置AutoCompleteTextView样式不起作用的相关知识,请在本站寻找。
本文标签: