android学习笔记

来源:互联网 发布:修改软件端口号 编辑:程序博客网 时间:2024/05/22 12:54
在学习Android编写样例时由于失误,将name打成了maem,然后自动导入了android.R.attr.name,很显然出现了错误。
在我输入用户名welkim后,显示的用户名为16842755这一串数字,好奇之心寻找了问题出现原因。
从API文档中发现这似乎是一个常量。

public static final int name

Added in API level 1

A unique name for the given item. This must use a Java-style naming convention to ensure the name is unique, for example "com.mycompany.MyName".

Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

Constant Value: 16842755 (0x01010003)
import static android.R.attr.name;public class ActivityTwo extends AppCompatActivity {    private TextView tv_name;    private TextView tv_password;    private TextView tv_sex;    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_02);        Intent intent=getIntent();        String name=intent.getStringExtra("name");        String password=intent.getStringExtra("password");        String sex=intent.getStringExtra("sex");        tv_name=(TextView) findViewById(R.id.tv_name);        tv_password=(TextView) findViewById(R.id.tv_password);        tv_sex=(TextView) findViewById(R.id.tv_sex);        tv_name.setText("用户名:"+name);        tv_password.setText("密码:"+password);        tv_sex.setText("性别:"+sex);    }
0 0
原创粉丝点击