我正在开发我的第一个"非教程"应用程序来增强和增强我的Android开发技能.
我一直在使用大量的Java Generics来增强可重用性和调试性,特别是因为我的许多片段对类的子类做了同样的事情Question.
我刚刚遇到了一个对我来说很新的传统模式,并且想知道我是否可以将它应用于Java中的通用类.
根据文本,newInstance(args,...)应该在Fragment类中创建一个方法来处理Intent Extras 到 Fragment Arguments的转换.
例:
SomeActivity.class
@?O?v?e?r?r?i?d?e?
p?r?o?t?e?c?t?e?d? ?F?r?a?g?m?e?n?t? ?c?r?e?a?t?e?F?r?a?g?m?e?n?t?(?)? ?{?
? ? ? ?r?e?t?u?r?n? ?n?e?w? ?ObjectF?r?a?g?m?e?n?t?(?)?;?
? ? ? ?U?U?I?D? ?object?I?d? ?=? ?(?U?U?I?D?)?g?e?t?I?n?t?e?n?t?(?)?
? ? ? ? ? ? ? ?.?g?e?t?S?e?r?i?a?l?i?z?a?b?l?e?E?x?t?r?a?(Object?F?r?a?g?m?e?n?t?.?E?X?T?R?A?_?OBJECT_?I?D?)?;?
? ? ? ?r?e?t?u?r?n? ?Object?F?r?a?g?m?e?n?t?.?n?e?w?I?n?s?t?a?n?c?e?(object?I?d?)?;?
}?
Run Code Online (Sandbox Code Playgroud)
ObjectFragment.class
p?u?b?l?i?c? ?s?t?a?t?i?c? ObjectF?r?a?g?m?e?n?t? ?n?e?w?I?n?s?t?a?n?c?e?(?U?U?I?D? ?object?I?d?)? ?{?
? ? ? ?B?u?n?d?l?e? ?a?r?g?s? ?=? ?n?e?w? ?B?u?n?d?l?e?(?)?;?
? ? ? ?a?r?g?s?.?p?u?t?S?e?r?i?a?l?i?z?a?b?l?e?(?E?X?T?R?A?_?C?R?I?M?E?_?I?D?,? ?object?I?d?)?;?
? ? ? ?ObjectF?r?a?g?m?e?n?t? ?f?r?a?g?m?e?n?t? ?=? ?n?e?w? ?ObjectF?r?a?g?m?e?n?t?(?)?;?
? ? ? …Run Code Online (Sandbox Code Playgroud) 我正在设计一个Android XML布局,其中包含一些表示复选标记和红色X图像的ImageView.我遇到了一些问题,这些图像在显示到屏幕时包含额外的边距/填充.

请注意,似乎没有右边距或左边距/填充,但有足够的顶部/底部填充.
这些图像是PNG格式,遵循http://developer.android.com/design/style/iconography.html中描述的创建小/上下文图标的准则.
我想通过使边距/填充匹配其水平边距/填充的效果来纠正问题.
这是布局的XML:
<!-- Event Reoccuring -->
<LinearLayout
android:id="@+id/event_reoccur_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="5dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
>
<TextView
android:id="@+id/kid_event_reoccur_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:layout_gravity="center_vertical"
android:text="@string/event_reoccur"
/>
<ImageView
android:id="@+id/kid_event_reoccur_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.1"
android:layout_gravity="center_vertical"
android:contentDescription="@string/indicator"
/>
<TextView
android:id="@+id/kid_event_reoccur"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:layout_gravity="center_vertical"
android:paddingLeft="4dp"
android:text="@string/not_applicable"
/>
</LinearLayout>
<!-- Age Required -->
<LinearLayout
android:id="@+id/event_age_req_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="16dp"
android:paddingRight="16dp"
>
<TextView
android:id="@+id/kid_event_age_req_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:layout_gravity="center_vertical"
android:text="@string/event_age_req"
/>
<ImageView
android:id="@+id/kid_event_age_req_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.1"
android:gravity="center_vertical"
android:contentDescription="@string/indicator"
/>
<TextView
android:id="@+id/kid_event_age_req"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.4" …Run Code Online (Sandbox Code Playgroud) 我试图使用awk格式化文件中的一些文本.
要求是用以下格式表示人类可读时间的格式化字符串替换表示纪元时间的冒号分隔文件(:)的第3个字段:DD/MM/YYYY
这是一个示例文件:
abc:$3$wHe$JKAP1Ry.CAcEGhD0J7SGVl.AMg.0:1427135400:0:120:7:30::
rst:$6$3WWbfvblr6FF92R5/n3mLdlSkARgfRm1:1427293800:0:40:7:30::
xyz:$1$xuTkkle203F$df.ixcn/mcuFIO90lndn:1420478400:0:90:7:30::
def:$4$vid2003mDEOF$dc2.Rkdlkfdiw8/cib6:1389547200:0:120:7:30::
ab:*$5P1wHeEG$JKA2ya.ikol30.de/ldiv.230:1449771300:0:120:7:30::
xy:$1k3lc930vs.lskdie/sldiemDIIsdk193n:1429995693:0:50:7:30::
xyy:*$tkwsMt972w.Csrl5jr.23nsoijsleqJK:1429995889:0:120:7:30::
Run Code Online (Sandbox Code Playgroud)
通过使用日期将第3个字段中的一个值复制并粘贴到命令中,我已经能够创建所需的结果:
date -d @1427135400 +"%d/%m/%Y"
23/03/2015
Run Code Online (Sandbox Code Playgroud)
这是我试图在脚本中执行的awk命令,我一直在推文脚本,希望能让它工作,但没有运气.请注意,$ userFound已经存储了上面列出的文件中的一行:
echo $userFound | awk -F':' '{
if ( $2 ~ /^\*/ ) {$2="L"} \
if ($2 ~ /^[^*]/) {$2="P"} \
cmd="date -d @"$3" +\"%d/%m/%Y\"" \
cmd | getline time \
close(cmd) \
} \
END { \
print $1":"$2":"time":"$4":"$5":"$6":"$7":"$8":"$9 \
}'
Run Code Online (Sandbox Code Playgroud)
运行当前脚本,我得到以下输出:
awk: cmd. line:5: (FILENAME=- FNR=1) fatal: expression for `|' redirection has null string value
Run Code Online (Sandbox Code Playgroud) 我经常使用C++并且遇到一个让我失望的简单错误.
在Xcode中,我有以下两个错误:在Event.h中:Control reaches end of non-void function
在Event.cpp中:Overloaded operator must have at least one argument of class or enumeration
这两个错误都在方法签名的行上
bool operator () (Event *left, Event *right)
Run Code Online (Sandbox Code Playgroud)
这里是完整的.h和.cpp文件(还没有那么多):Event.h
#ifndef __EventSimulation__EventComparison__
#define __EventSimulation__EventComparison__
#include <iostream>
#include "Event.h"
class EventComparison {
public:
bool operator () (Event *left, Event *right){}
};
#endif
Run Code Online (Sandbox Code Playgroud)
Event.cpp
#include "EventComparison.h"
#include "Event.h"
bool operator() (Event *left, Event *right) {
return left->time > right->time;
}
Run Code Online (Sandbox Code Playgroud)
有人可以帮我修复这个错误并解释什么/为什么发出编译错误以及如何在功能中避免这种情况.谢谢你的帮助!