一、打log。

代码如下:

package com.example.hello;

import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        Log.v("fighting", "章泽天是java程序员的女神1");
        Log.d("fighting","章泽天是allen的女神2");
        Log.i("fighting", "我们都喜欢章泽天3");
        Log.w("fighting", "章泽天~~~~~4");
        Log.v("fighting", "加油!!!5");
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
    
}


2、看log

      1)logcat

       单击,logcat,我们可以在该透视图中看到以下界面:

   android中log的使用_Android

   2)android中log的使用_android_02(新建log过滤器,主要用于在众多的log中找到自己需要的)

       单击上面的绿色的十字架,我们可以看到以下界面:

       android中log的使用_ide_03 


这时,我们便能很方便的找到自己所需要的log。。其实1)中所用的图就是使用过滤器后得到的log。