Chinaunix首页 | 论坛 | 博客
  • 博客访问: 868832
  • 博文数量: 322
  • 博客积分: 6688
  • 博客等级: 准将
  • 技术积分: 3626
  • 用 户 组: 普通用户
  • 注册时间: 2010-09-19 11:26
文章分类

全部博文(322)

文章存档

2013年(5)

2012年(66)

2011年(87)

2010年(164)

分类: Java

2010-12-31 11:09:17

日志输入

LogActivity

Java代码

package org.wp.activity;  
 
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;  
 
/**
 *
 * 调整日志输出的级别
 * Eclipse ==> Window ==> Preferences ==> Android ==> DDMS ==> Logging Level
 * 日志输入
 * Eclipse ==> Window ==> Show View ==> Other ==> Android ==> LogCat
 *
 * @author wp
 *
 */  
 
public class LogActivity extends Activity {
    private static final String TAG = "LogActivity"; // 快捷键ctrl+shift+x  
 
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Log.i(TAG, "LogActivity Created");
    }
}

单元测试()

LogTest

Java代码

package org.wp.activity;  
 
import android.test.AndroidTestCase;
import android.util.Log;  
 
/**
 * JunitRun ==> LogTest(实例化) ==> testSave()
 * Debug
 * Step Into F5
 * Step Over F6
 * Run to Line Ctrl + R
 * Step Return F7
 *
 * @author wp
 *
 */  
 
public class LogTest extends AndroidTestCase {  
 
    private static final String TAG = "LogTest";  
 
    public void testSave() throws Exception {
        int i = 1 + 1;
        String result = practice(i);
        Log.i(TAG, "result=" + i);
        Log.i(TAG, "result=" + result);
    }  
 
    private String practice(int i) {
        int a = i;
        int b = 100;
        int c = a + b;
        String out = "wp";
        String result = out + c;
        return result;
    }
}

AndroidManifest.xml

Xml代码

阅读(653) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2011-01-02 12:11:38

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com