Android HelloWord 编写方式介绍
2010-02-10 06:45:00 来源:WEB开发网核心提示:2).设置监听和跳转actiovityJava代码package com.layout; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.V
2).设置监听和跳转actiovity
Java代码
- package com.layout;
- import android.app.Activity;
- import android.content.Intent;
- import android.os.Bundle;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.widget.Button;
- public class Layout extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- OnClickListener listener1 = null;
- Button botton1 = null;
- listener1 = new OnClickListener(){
- public void onClick(View v) {
- Intent intent0 = new Intent(Layout.this,
ActivityFrameLayout.class);- setTitle("FrameLayout");
- startActivity(intent0);
- }
- };
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- botton1 = (Button) findViewById(R.id.button1);
- botton1.setOnClickListener(listener1);
- }
- }
- package com.layout;
- import android.app.Activity;
- import android.content.Intent;
- import android.os.Bundle;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.widget.Button;
- public class Layout extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- OnClickListener listener1 = null;
- Button botton1 = null;
- listener1 = new OnClickListener(){
- public void onClick(View v) {
- Intent intent0 = new Intent(Layout.this,
ActivityFrameLayout.class);- setTitle("FrameLayout");
- startActivity(intent0);
- }
- };
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- botton1 = (Button) findViewById(R.id.button1);
- botton1.setOnClickListener(listener1);
- }
- }
更多精彩
赞助商链接