Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to output the ArrayList and HashMap #34

Closed
guoyoujin opened this issue Jun 21, 2015 · 8 comments
Closed

how to output the ArrayList and HashMap #34

guoyoujin opened this issue Jun 21, 2015 · 8 comments

Comments

@guoyoujin
Copy link

Excuse me, would you please tell me how to use this package, how to output the ArrayList and HashMap,
7683-7683/com.guoyoujin.gz.gz E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.util.UnknownFormatConversionException: Conversion: '
at java.util.Formatter$FormatToken.unknownFormatConversionException(Formatter.java:1397)
at java.util.Formatter$FormatToken.checkFlags(Formatter.java:1334)
at java.util.Formatter.transform(Formatter.java:1440)
at java.util.Formatter.doFormat(Formatter.java:1079)
at java.util.Formatter.format(Formatter.java:1040)
at java.util.Formatter.format(Formatter.java:1009)
at java.lang.String.format(String.java:1992)
at java.lang.String.format(String.java:1966)
at com.orhanobut.logger.LoggerPrinter.createMessage(LoggerPrinter.java:346)
at com.orhanobut.logger.LoggerPrinter.log(LoggerPrinter.java:211)
at com.orhanobut.logger.LoggerPrinter.i(LoggerPrinter.java:138)
at com.orhanobut.logger.Logger.i(Logger.java:61)
at com.guoyoujin.gz.gz.fragment.tabfragment.Fragment1$GetNewsDataThread$1.run(Fragment1.java:129)
at android.os.Handler.handleCallback(Handler.java:800)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5463)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:854)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:621)
at dalvik.system.NativeStart.main(Native Method)

private ArrayList list;

public class NewsVo {
private String newsId;
private String title;
private String content;
private String videoAndriodURL;
private String videoIphoneURL;
private NewsImageVo image;
private String date;

public String getNewsId() {
    return newsId;
}
public void setNewsId(String newsId) {
    this.newsId = newsId;
}
public String getTitle() {
    return title;
}
public void setTitle(String title) {
    this.title = title;
}
public String getContent() {
    return content;
}
public void setContent(String content) {
    this.content = content;
}
public String getVideoAndriodURL() {
    return videoAndriodURL;
}
public void setVideoAndriodURL(String videoAndriodURL) {
    this.videoAndriodURL = videoAndriodURL;
}
public String getVideoIphoneURL() {
    return videoIphoneURL;
}
public void setVideoIphoneURL(String videoIphoneURL) {
    this.videoIphoneURL = videoIphoneURL;
}
public NewsImageVo getImage() {
    return image;
}
public void setImage(NewsImageVo image) {
    this.image = image;
}
public String getDate() {
    return date;
}
public void setDate(String date) {
    this.date = date;
}

@Override
public String toString() {
    return "NewsVo{" +
            "newsId='" + newsId + '\'' +
            ", title='" + title + '\'' +
            ", content='" + content + '\'' +
            ", videoAndriodURL='" + videoAndriodURL + '\'' +
            ", videoIphoneURL='" + videoIphoneURL + '\'' +
            ", image=" + image +
            ", date='" + date + '\'' +
            '}';
}

}

@orhanobut
Copy link
Owner

can you show how do you use Logger? It seems that it is not used correctly. Logger only accepts String for the message.

@guoyoujin
Copy link
Author

@orhanobut ok,
ArrayList list;
Logger.e(list.toString(),"message");

@orhanobut
Copy link
Owner

second parameter is the argument and I assume that videoAndriodURL or videoIphoneURL has something "%20". That's why probably you get a crash because String.formatter cannot resolve 20.

@guoyoujin
Copy link
Author

@orhanobut Very thank you for your answer,Yes, because I defined object inside a ImageUrl, he is the image resources links, there may be some special characters you said, is there any way to solve this problem?

@orhanobut
Copy link
Owner

you need to escape the % character by using double "%%"

@guoyoujin
Copy link
Author

@orhanobut Ok, thank you very much

@AAverin
Copy link

AAverin commented Apr 14, 2017

I have replaced all println's in my code with the logger, and now get lots of these UnknownFormatConversionExceptions. It seems that default System.out didn't have any issues printing my objects.

@AAverin
Copy link

AAverin commented Apr 14, 2017

Also, default Log.d("", message) works fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants