我试图在 RecyclerView 中为孩子设置重力,但看起来 LayoutParams 没有重力方法。我尝试了以下方法:
RecyclerView.LayoutParams params = new RecyclerView.LayoutParams(
RecyclerView.LayoutParams.WRAP_CONTENT, RecyclerView.LayoutParams.WRAP_CONTENT);
Run Code Online (Sandbox Code Playgroud)
我还尝试了以下方法:
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
Run Code Online (Sandbox Code Playgroud)
在这两种情况下都params.setMargin(int, int, int, int)可以正常工作并且边距设置正确。
我的 RecyclerView:
<android.support.v7.widget.RecyclerView
android:id="@+id/messages_list_view"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar"
android:layout_marginTop="20dp"/>
Run Code Online (Sandbox Code Playgroud)
我的相对布局(RecyclerView 的孩子):
<RelativeLayout
android:id="@+id/message_text_wrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:background="@drawable/chat_bubble"
android:layout_margin="16dp"
android:padding="10dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:id="@+id/message_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:textColor="@android:color/primary_text_light"
android:textSize="18sp"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我想要做的是params.setGravity(int)或任何其他使这成为可能的黑客。谢谢。
我是Python的新手,在这个脚本之后,我可能根本不会使用Python.我正在使用Scrapy提取一些数据并且必须过滤掉一些字符串(我已经使用isdigit()完成了这个数字).谷歌搜索给了我关于过滤掉特殊字符串的页面,但我想要的只是一个较大字符串的一小部分.
这是字符串:
Nima Python: how are you?
Run Code Online (Sandbox Code Playgroud)
我想要的还有:
how are you?
Run Code Online (Sandbox Code Playgroud)
所以这部分删除了:
Nima Python:
Run Code Online (Sandbox Code Playgroud)
先谢谢你们.
我有一个div,其中包含一个table。一切工作,我想,除了我不知道如何设置width的div,这样它的增长作为width了的table它的增长里面。我怎样才能做到这一点?谢谢。
这是的CSS代码div:
#events-table-wrapper {
margin-left: auto;
margin-right: auto;
width: 500px;
margin-top: 100px;
border: 1px solid #CCC;
border-radius: 4px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
}
Run Code Online (Sandbox Code Playgroud)
设置width为auto无济于事。顺便说一句,我没有更改CSS表中的任何内容。
编辑:这是一个实时版本:http : //jsfiddle.net/ZDF2U/
我有一个评论框,让用户按回车发表评论.它使用AJAX(jQuery)请求执行此操作.如果事件在上一条评论的5秒内显示并显示消息,是否有一种不让事件触发的好方法?或者这应该在服务器端处理?
对不起,如果我的问题听起来很奇怪,我会试着解释一下.我有4个班:Karakter,Karakters,Orc,Human.兽人和人类都延伸了卡拉克特.Karakters是一个带有Karakter的ArrayList.
我在Orc和Human中都有一个方法叫做:public String getRace().现在我想在Karakters中使用这种方法?!! 当我尝试这样做时,它失败了,因为Orc和Human扩展了Karakter而不是Karakters!有没有办法做到这一点?我听到了一些关于制作抽象的东西:P
谢谢
我想围绕这个双倍:
3.499999999999999
Run Code Online (Sandbox Code Playgroud)
至:
3.50
Run Code Online (Sandbox Code Playgroud)
我已经使用了这两种方法:
DecimalFormat df = new DecimalFormat("0.00");
double result = Double.valueOf(df.format(input));
System.out.println(answer);
Run Code Online (Sandbox Code Playgroud)
和
public double round(double input)
{
int decimalPlace = 2;
BigDecimal bd = new BigDecimal(input);
bd = bd.setScale(decimalPlace,BigDecimal.ROUND_UP);
return (bd.doubleValue());
}
Run Code Online (Sandbox Code Playgroud)
但它继续印刷:
3.5
Run Code Online (Sandbox Code Playgroud)
有人有解决方案吗?因为我真的认为这应该有效.谢谢你的帮助.
我有一个带有questions集合的 Cloud Firebase 数据库。每个question都有一个 map 列表options。我正在使用 Flutter 并为questionand 提供以下类option:
class Question {
final String text;
final List<Option> options; // I have tried changing this to List<dynamic> but it doesn't help
final String reference;
Question(this.text, this.options, this.reference);
Question.fromMap(Map<String, dynamic> map, {this.reference}) :
text = map['text'],
options = map['options']; // here the error happens
Question.fromSnapshot(DocumentSnapshot snapshot)
: this.fromMap(snapshot.data, reference: snapshot.documentID);
}
Run Code Online (Sandbox Code Playgroud)
和 option
class Option {
final String text;
final int votes; …Run Code Online (Sandbox Code Playgroud) body{
font-family:"Arial","Lucida Grande", "Lucida Sans Unicode", Verdana, Helvetica, sans-serif;
font-size:12px;
}
p, h1, form, button{border:0; margin:0; padding:0;}
.spacer{clear:both; height:1px;}
/* ----------- My Form ----------- */
.myform{
margin:0 auto;
width:450px;
padding:14px;
}
/* ----------- regForm ----------- */
#regForm{
border:solid 2px #b7ddf2;
background:#A9D0F5;
}
#regForm h1 {
font-size:18px;
font-weight:bold;
margin-bottom:8px;
}
#regForm p{
font-size:11px;
color:#666666;
margin-bottom:20px;
border-bottom:solid 1px #b7ddf2;
padding-bottom:10px;
}
#regForm label{
display:block;
font-weight:bold;
text-align:right;
width:140px;
float:left;
}
#regForm .small{
color:#666666;
display:block;
font-size:11px;
font-weight:normal;
text-align:right;
width:140px;
}
#regForm input{
float:left;
font-size:100%; …Run Code Online (Sandbox Code Playgroud) 我正在使用以下正则表达式代码:
^[a-z0-9_-]{3,15}$^
Run Code Online (Sandbox Code Playgroud)
我使用该用户名的验证,我希望它匹配字母数字字符,-,_和句号.
发生以下奇怪的事情:
它与此不匹配:
bla.b
Run Code Online (Sandbox Code Playgroud)
但它匹配这个:
bla.blabla
Run Code Online (Sandbox Code Playgroud)
我怎样才能更改它,以便它们兼容?我仍然希望能够自由地改变最小和最大字符.(顺便说一句.关于这个正则表达式可能有更多错误的东西.这是我意外发现的)
更新:我应该提一下,我在CakePHP验证中使用它,这给了我一个错误:
^[a-z0-9_.-]{3,15}$
Run Code Online (Sandbox Code Playgroud)
这是错误:
Warning (2): preg_match() [function.preg-match]: No ending delimiter '^' found
Run Code Online (Sandbox Code Playgroud)