disply',' if title is empty?

Moderators: dwp, devin

Post Reply
oldman1881
Posts: 47
Joined: Sat Sep 28, 2013 1:29 am

disply',' if title is empty?

Post by oldman1881 »

checked title field i am sure it is empty and no space.
suggest to trim the title filed before put ','
devin
Posts: 1337
Joined: Fri Oct 11, 2013 10:16 am

Re: disply',' if title is empty?

Post by devin »

Code: Select all

if (TextUtils.isEmpty(company)) {
        combined = displayNameIsOrganization ? null : title;
} else {
        if (TextUtils.isEmpty(title)) {
                combined = displayNameIsOrganization ? null : company;
        } else {
                if (displayNameIsOrganization) {
                        combined = title;
                } else {
                        combined = context.getString(
                                R.string.organization_company_and_title, company, title);
                }
        }
}
Hello, this is the code, which title has been determined is empty. Only when the title contains a space will cause you mentioned. Maybe your contacts is a merge contacts. In one account he was not edited in the phone. But it contains spaces.
oldman1881
Posts: 47
Joined: Sat Sep 28, 2013 1:29 am

Re: disply',' if title is empty?

Post by oldman1881 »

呵呵,n多年没有做coding了。不知道android里有没有trim这样的功能,就是如果有一个string :space+space+ABC+space+space,trim以后就只有ABC了,可以把space弄掉。 这样就不会遗留一个空白的space的问题。
devin
Posts: 1337
Joined: Fri Oct 11, 2013 10:16 am

Re: disply',' if title is empty?

Post by devin »

这里没有使用trim。只是判断String是否为空。因此有空格会导致“,”出现。我之前是这样回答的。
oldman1881
Posts: 47
Joined: Sat Sep 28, 2013 1:29 am

Re: disply',' if title is empty?

Post by oldman1881 »

建议使用trim,以前做coding的时候,我们判断string都是先trim一下,再判断的,不然A和A+space会不一样。
devin
Posts: 1337
Joined: Fri Oct 11, 2013 10:16 am

Re: disply',' if title is empty?

Post by devin »

恩谢谢!有较多联系人出现这个情况吗?如果是个别建议修改一下联系人。因为是手机我想减少不必要的代码。
oldman1881
Posts: 47
Joined: Sat Sep 28, 2013 1:29 am

Re: disply',' if title is empty?

Post by oldman1881 »

devin wrote:恩谢谢!有较多联系人出现这个情况吗?如果是个别建议修改一下联系人。因为是手机我想减少不必要的代码。
不是很多,是大多联系人有这个问题,因为大多都联络人是只有公司,没有职位。
所以至少这段码用trim处理一下。
devin
Posts: 1337
Joined: Fri Oct 11, 2013 10:16 am

Re: disply',' if title is empty?

Post by devin »

好的,但是在我的手机没有这个问题。因为当联系人没有职位,相关的字段将是空,而不是空格。
oldman1881
Posts: 47
Joined: Sat Sep 28, 2013 1:29 am

Re: disply',' if title is empty?

Post by oldman1881 »

devin wrote:好的,但是在我的手机没有这个问题。因为当联系人没有职位,相关的字段将是空,而不是空格。
其实应该是空的,不知道为什么会是空格。
devin
Posts: 1337
Joined: Fri Oct 11, 2013 10:16 am

Re: disply',' if title is empty?

Post by devin »

恩,我已经修改它。并做一些优化在t9搜索,如果有时间,请试试它。
http://www.dw-p.net/dl/DW-Contacts-Phone-test.apk
oldman1881
Posts: 47
Joined: Sat Sep 28, 2013 1:29 am

Re: disply',' if title is empty?

Post by oldman1881 »

devin wrote:恩,我已经修改它。并做一些优化在t9搜索,如果有时间,请试试它。
http://www.dw-p.net/dl/DW-Contacts-Phone-test.apk
ok了,谢谢。
不过backup和restore还是要手改文件路径,可否像settting restore一样有file browser功能,可以自己选。
devin
Posts: 1337
Joined: Fri Oct 11, 2013 10:16 am

Re: disply',' if title is empty?

Post by devin »

好的,我试试
oldman1881
Posts: 47
Joined: Sat Sep 28, 2013 1:29 am

Re: disply',' if title is empty?

Post by oldman1881 »

using test version now, not sure why it has 'system not responding' problem very often.
do you know why?
devin
Posts: 1337
Joined: Fri Oct 11, 2013 10:16 am

Re: disply',' if title is empty?

Post by devin »

What is the function you are using?
Please try this final version.
http://www.dw-p.net/dl/DW-Contacts-Phone.apk
oldman1881
Posts: 47
Joined: Sat Sep 28, 2013 1:29 am

Re: disply',' if title is empty?

Post by oldman1881 »

I donot use any complicate function, just start dialer, then the system show me unresponding and it is very often.
oldman1881
Posts: 47
Joined: Sat Sep 28, 2013 1:29 am

Re: disply',' if title is empty?

Post by oldman1881 »

I donot use any complicate function, just start dialer, then the system show me unresponding and it is very often.
devin
Posts: 1337
Joined: Fri Oct 11, 2013 10:16 am

Re: disply',' if title is empty?

Post by devin »

Please try this final version
http://www.dw-p.net/dl/DW-Contacts-Phone.apk
Post Reply