当我尝试运行我的应用程序时出现以下错误:
Error:Execution failed for task ':app:compileDevelopmentDebugJavaWithJavac'.
> java.lang.RuntimeException: Found data binding errors.
****/ data binding error ****msg:Could not find accessor java.lang.String.giftRecipientName redacted.xml loc:182:63 - 182:93 ****\ data binding error ****
Run Code Online (Sandbox Code Playgroud)
我有一个Order对象,如下所示:
public class Order {
public Address address;
// unrelated fields and methods
}
Run Code Online (Sandbox Code Playgroud)
嵌套的Address对象如下所示:
public class Address {
public String addressLine1;
public String addressLine2;
public String giftRecipientName;
public Boolean isGift;
}
Run Code Online (Sandbox Code Playgroud)
在我的.xml中,我正在执行以下操作:
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable name="order" type="example.redacted.models.Order"/>
</data>
// widgets and whatnot
<TextView
android:id="@+id/gift_recipientTV"
android:layout_column="1"
android:layout_weight="1"
android:layout_width="0dp"
android:textStyle="bold" …Run Code Online (Sandbox Code Playgroud) 我正在从这个站点http://www.ocpsoft.org/prettytime/实现漂亮的时间库, 以在我的 android 应用程序中获取带有文本的格式化日期字符串。
我将我的日期作为本地 sqlite 数据库中的字符串输入,
String dateString="2015-09-25 15:00:47";
SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss aa");
Date convertedDate = new Date();
try {
convertedDate = dateFormat.parse(dateString);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
PrettyTime p = new PrettyTime();
String datetime= p.format(convertedDate);
textview.setText(datetime);
Run Code Online (Sandbox Code Playgroud)
我希望能够让我的日期格式parsetext类似
2 minutes ago
1 day ago
...
Run Code Online (Sandbox Code Playgroud)
然而,上面的代码片段只给了我文本并避免了时间。这就是它给出的
minutes ago
...
Run Code Online (Sandbox Code Playgroud)
请问有什么需要我做的吗,如果有人能提供帮助,我将不胜感激。谢谢
我有一个LocationReceiver曾经从一个FusedLocationProviderApi.KEY_LOCATION_CHANGED提取Location一个Intent.但是现在KEY_LOCATION_CHANGED被弃用了我应该把它更改为什么?
当前代码:
@Override
public void onReceive(Context context, Intent intent) {
final Location location = (Location) intent.getExtras().get(FusedLocationProviderApi.KEY_LOCATION_CHANGED);
if (location != null) {
float accuracy = location.getAccuracy();
Log.d(LocationReceiver.class.getSimpleName(), "*** Accuracy is: " + accuracy + " ***");
} else {
Log.d(LocationReceiver.class.getSimpleName(), "*** location object is null ***");
}
}
Run Code Online (Sandbox Code Playgroud)