初学Android中用id来进行xml中的控件获取

来源:互联网 发布:软件可靠性方法 编辑:程序博客网 时间:2024/05/18 06:19
//获取textView对象TextView textView = (TextView) findViewById(R.id.tv_hello);//获取文本内容String text=textView.getText().toString();Log.i("xzn",text);//吐司Toast.makeText(this,text,Toast.LENGTH_LONG).show();//设置文本内容textView.setText("修改后的text");textView.setTextColor(getResources().getColor(R.color.red));