Android基础教程之仿Iphone 拖动相片特效Gallery的简单应用.
2010-07-15 21:03:00 来源:WEB开发网/>
< Button
android:id="@+id/bt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Presse Me Look Log"
/>
< /LinearLayout>
Step 4:设计主类LogDemo.java,代码如下:
package com.android.test;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
public class LogDemo extends Activity {
private static final String ACTIVITY_TAG="LogDemo";
private Button bt;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//通过findViewById找到Button资源
bt = (Button)findViewById(R.id.bt);
//增加事件响应
bt.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View v) {
Log.v(LogDemo.ACTIVITY_TAG, "This is Verbose.");
Log.d(LogDemo.ACTIVITY_TAG, "This is Debug.");
Log.i(LogDemo.ACTIVITY_TAG, "This is Information");
Log.w(LogDemo.ACTIVITY_TAG, "This is Warnning.");
Log.e(LogDemo.ACTIVITY_TAG, "This is Error.");
}
});
}
}
Step 5:运行LogDemo工程,效果如下:
当我们点击按钮时,会触发事件,在Logcat视窗下有如下效果:
Ok~这个暂时就先讲到这里,有什么不懂的,或者想要源码的,留下你们的Email地址,我会发给你们的,顺便祝大家节日快乐!
更多精彩
赞助商链接