Android现学现用第一天

1.Mac 系统下Eclipse还是挺好用的,苹果对于Android的支持不错。Mac下的Eclipse的菜单在最上面的苹果菜单栏里,不要乱翻了。使用起来和Windows下的Eclipse差不多。

2.src,gen和res是三个主要的部分。src是java源码部分,gen是自动生成的,res里是图片资源和页面控件,draw里面是图片,layout中的xml是控件信息,这里更改后保存,gen中直接就变了。value是一些变量的值。

3.layout xml中注册控件是这样的:

<Button  

    android:id="@+id/report_button"

    android:layout_width="fill_parent" 

    android:layout_height="wrap_content" 

    android:text="Report YAMI!"

    />

gen中的R类里是这样自动生成的:

 public static final class id {

        public static final int report_button=0x7f050001;

        public static final int search_button=0x7f050000;

        public static final int textview=0x7f050002;

    }

SRC中是这样引用的:

public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);

        search_now();

        report_now();

    }

private Button.OnClickListener button_report_listener = new Button.OnClickListener(){

    @Override

public void onClick(View v) {

//跳转页面

    setTitle("To indicate report!");

}

    };

private void report_now(){

    Button button_report = (Button)findViewById(R.id.report_button);

button_report.setOnClickListener(button_report_listener);

}

直接定义监听器,在方法中就把button控件定义好了,在把定义好的监听器放进去就行。

最后加一句,helloworld创建工程后直接就能显示出来了,不用找源代码了。甚至不需要以前还要system.out.println...白找了那么久

posted on 2011-09-01 22:23  Wind Runner  阅读(155)  评论(0编辑  收藏  举报

导航