(文件1)新建文本文档.txtimportandroid.app.Activity; importandroid.os.Bundle; importandroid.util.Log; importandroid.widget.Button; importandroid.widget.EditText; importandroid.widget.TextView; importandroid.util.Log; public class RelativeLayout extends Activity { final static String TAG = "LOGCAT"; privateTextViewtv = null; privateEditText et = null; private Button btn1 = null; private Button btn2 = null;
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); tv = (TextView)findViewById(R.id.label); et = (EditText)findViewById(R.id.entry); btn1 = (Button)findViewById(R.id.cancel); btn2 = (Button)findViewById(R.id.ok); tv.setText(R.string.name); btn1.setText(R.string.button1); btn2.setText(R.string.button2); Log.v(TAG, "This is Verbose"); Log.d(TAG, "This is Debug"); Log.i(TAG, "This is Info"); Log.w(TAG, "This is Warn"); Log.e(TAG, "This is Error"); } }