android helloworld级别学习

1、什么是appcompat_v7?

    新建android项目时,会在工作空间多出一个文件appcompat_v7,它的主要作用是可以让2.1以上全使用4.0版本的界面支持库。

    详细可以参考百度经验:http://jingyan.baidu.com/album/3ea51489e04eb852e61bbaa4.html


2、android一定要创建虚拟设备吗

    不一定,只是没有手机的情况下才需要


3、android中的 context 如何理解?


4、andorid 引用另外一个工程

    设置步骤:选中工程右键  -->  Build Path  -->  Configure Build Path...  -->  Android  -->  Library  -->  Add  -->  选中所需添加的工程即可


5、如何导入 android 工程

    详细参见百度经验:http://jingyan.baidu.com/article/a65957f4983d9e24e77f9b70.html


6、setContentView(int layoutResID)

/**
     * Convenience for
     * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}
     * to set the screen content from a layout resource.  The resource will be
     * inflated, adding all top-level views to the screen.
     *
     * @param layoutResID Resource ID to be inflated.
     * @see #setContentView(View, android.view.ViewGroup.LayoutParams)
     */
    public abstract void setContentView(int layoutResID);

    根据注释我们可以看到:从一个布局资源中设置屏幕内容。意思就是将布局内容展现到屏幕上。


7、findViewById(int id)
/**
     * Finds a view that was identified by the id attribute from the XML that
     * was processed in {@link #onCreate}.
     *
     * @return The view if found or null otherwise.
     */
    public View findViewById(int id) {
        return getWindow().findViewById(id);
    }

从一个 XML 布局文件中找到属性为 id 的 view,这里的 view 就好比之前接触 SWT 中的组件,android 中的常用组件有这些:
TextView:文本显示控件
Button:按钮控件
EditText:可编辑的文本控件
CheckBox:复选框控件
RadioGroup:单选框组件
Spinner:下拉列表框组件
DatePicker:日期选择控件
ScrollView:滚动条组件
ProgressBar:进度条
SeekBar:拖动条
RatingBar:评分
ImageView:图片显示
ImageButton:图片按钮
AutoCompleteTextView:自动完成文本组件
Dialog:对话框组件
Toast:信息提示
Menu:菜单显示组件

8、Handler 线程调用 sendEmptyMessage 方法会自动去调用 handleMessage方法
/**
     * Subclasses must implement this to receive messages.
     */
    public void handleMessage(Message msg) {
    }

9、 android.os.AsyncTask 作用
    AsyncTask 主要用来异步调用。在这个类里面有几个常用到的方法,执行顺序如下:
/**
     * Runs on the UI thread before {@link #doInBackground}.
     *
     * @see #onPostExecute
     * @see #doInBackground
     */
    protected void onPreExecute() {
    }

/**
     * Override this method to perform a computation on a background thread. The
     * specified parameters are the parameters passed to {@link #execute}
     * by the caller of this task.
     *
     * This method can call {@link #publishProgress} to publish updates
     * on the UI thread.
     *
     * @param params The parameters of the task.
     *
     * @return A result, defined by the subclass of this task.
     *
     * @see #onPreExecute()
     * @see #onPostExecute
     * @see #publishProgress
     */
    protected abstract Result doInBackground(Params... params);

/**
     * <p>Runs on the UI thread after {@link #doInBackground}. The
     * specified result is the value returned by {@link #doInBackground}.</p>
     * 
     * <p>This method won't be invoked if the task was cancelled.</p>
     *
     * @param result The result of the operation computed by {@link #doInBackground}.
     *
     * @see #onPreExecute
     * @see #doInBackground
     * @see #onCancelled(Object) 
     */
    @SuppressWarnings({"UnusedDeclaration"})
    protected void onPostExecute(Result result) {
    }











评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值