Alog转换为Java

时间:2012-02-02 07:04:34

标签: java android objective-c eclipse

如何在Android或Java中转换使用此代码,因为它是用Objective C编写的?

ALog(@"ERROR: Account with UserId:%@ AccountType:%d AccoundId:%d DOES NOT EXIST!",
     account.userId, account.accountType, account.accountId);

2 个答案:

答案 0 :(得分:1)

看一下MessageFormat类:

http://docs.oracle.com/javase/1.4.2/docs/api/java/text/MessageFormat.html

还有一些日志框架,比如log4j,commons-logging或者你觉得最方便的任何东西

答案 1 :(得分:0)

嗯,对于Android,您需要执行以下操作:

Log.i("AccountActivity", "Account with UserId: " + userId +
      " AccountType: " + accountType +
      " AccountId: " + accountId +
      " Does not exist.");

这将出现在由活动和级别(在本例中为info)格式化的logcat中。可能看起来像这样:

I/AccountActivity( 1234): Account with UserId: {id} AccountType: {type} AccountId: {id} Does not exist.

不确定这是否可以回答您的问题...请点击此处获取进一步的帮助:http://developer.android.com/guide/developing/debugging/debugging-log.html