一个非常奇怪的问题。我想通过此规则更新联系人姓名: - 如果联系人的姓名以“bit”+ space(“bit”)开头,那么 - >将联系人的姓名更新为name.substring(4,name.length()),这意味着联系人名称将更新而不会显示“位”。
当我使用name.substring从数字降低它们4(我想直到联系人姓名中的空格)它完美地工作。当我从4个字符开始使用时,联系人的名字会相乘。例如,当我使用name = name.substring(4,name.length())而名称等于“bit Lili”时,它更新为: 莉莉丽丽。
private void updateContact(String name) {
ContentResolver cr = getContentResolver();
String where = ContactsContract.Data.DISPLAY_NAME + " = ?";
String[] params = new String[] {name};
Cursor phoneCur = managedQuery(ContactsContract.Data.CONTENT_URI,null,where,params,null);
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
if ((null == phoneCur)) {//createContact(name, phone);
Toast.makeText(this, "no contact with this name", Toast.LENGTH_SHORT).show();
return;} else {ops.add(ContentProviderOperation.newUpdate(android.provider.ContactsContract.Data.CONTENT_URI)
.withSelection(where, params)
.withValue(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME, name.substring(4,name.length()))
.build());
}
phoneCur.close();
try {cr.applyBatch(ContactsContract.AUTHORITY, ops);}
catch (RemoteException e) {e.printStackTrace();}
catch (OperationApplicationException e) {e.printStackTrace();}}
谢谢!
答案 0 :(得分:0)
不是一定的答案,但它假设你使用的问题是
library(data.table)
library(ggplot2)
mdt <- dt[, .(value = mean(value)), by = .(name, date)]
ggplot(dt, aes(date, value)) +
geom_line(aes(group = type, col = name)) +
geom_line(data = mdt[name == "A"], col = "#ff5a32", size = 2) +
geom_line(data = mdt[name == "B"], col = "#475cd3", size = 2) +
scale_colour_manual(name = "Name",
values = c("#ff987f", "#8c99e4")) +
labs(x = "Date",
y = "Value",
title = "Change in value over time") +
theme_classic()
所以我的修复建议是将其更改为姓氏,并根据您的问题根据您的问题更改这些名称,以便删除给定名称,以便对此进行修复
.withValue(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME //This specific part has a problem with the new update function
,name.substring(4,name.length()))