Android——学习笔记

1、this注意

@Override
            public void onItemSelected(AdapterView<?> parent, View view,
                    int position, long id) {
                Toast.makeText(TryActivity.this, "您选择的是:"+parent.getItemAtPosition(position), Toast.LENGTH_SHORT).show();
            }//不加加粗的类名会报错

2、退出应用

@Overridehttp://i.cnblogs.com/EditPosts.aspx?postid=4373386
            public void onClick(View v) {
                // 处理按钮事件
                ButtonActivity.this.finish();//
            }

3、文本框聚焦

<EditText
        android:id="@+id/userName"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="20dip"
        android:layout_marginRight="20dip"
        android:autoText="false"
        android:capitalize="none"
        android:gravity="fill_horizontal"
        android:hint="用户名XXX"
        android:scrollHorizontally="true"
        android:textAppearance="?android:attr/textAppearanceMedium" >

        <requestFocus />
    </EditText>

4、drawable系统调用

density值表示每英寸有多少个显示点,与分辨率是两个概念。

当屏幕density=240时使用hdpi标签的资源
当屏幕density=160时,使用mdpi标签的资源
当屏幕density=120时,使用ldpi标签的资源。
不加任何标签的资源是各种分辨率情况下共用的。
布局时尽量使用单位dip,少使用px

5、Android中通过typeface设置字体textAppearance设置文字外观

6、android:autoText="true"自动拼写帮助
原文地址:https://www.cnblogs.com/Defry/p/4373386.html