安卓第七天
TextView和EditText
TextView:
android:autoLink属性的应用
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/autotx"
<TextView
android:id="@+id/tvWebUrl"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:autoLink="web"/>
<TextView
android:id="@+id/tvEmail"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:autoLink="email"/>
<TextView
android:id="@+id/tvPhone"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:autoLink="phone"/>
<TextView
android:id="@+id/tvMap"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:autoLink="map"/>
<TextView
android:id="@+id/tvAll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:autoLink="all"
android:text="我的博客:http://blog.csdn.net/jiahui524。 手机号码:15580974038.邮箱:[email protected]" />
private void findViews(){
TextViewtvWebUrl = (TextView)findViewById(R.id.tvWebUrl);
tvWebUrl.setText("网易:http://www.163.com");
TextViewtvEmail,tvPhone, tvMap ,tvHtml;
tvEmail= (TextView) this.findViewById(R.id.tvEmail);
tvPhone= (TextView) this.findViewById(R.id.tvPhone);
tvMap= (TextView) this.findViewById(R.id.tvMap);
tvHtml= (TextView)this.findViewById(R.id.tvHtml);
tvEmail.setText("我的邮箱:[email protected]");
tvPhone.setText("我的电话:500000");
tvHtml.setText(Html.fromHtml("<font size='33' color='#333333'>我<i>爱</i>北</font>京天<b>安</b>门/n<br/>" +
"<ahref='http://www.163.com'>163</a>"));
}
关于9patch
它是一个对png图片做处理的一个工具,能够为我们生成一个"*.9.png"的图片;
所谓"*.9.png"这是Android os里所支持的一种特殊的图片格式,用它可以实现部分拉伸;这种图片是经过”9妹“进行特殊处理过的,如果不处理的话,直接用PNG图就会有失真,拉伸不正常的现象出现。
EditText中回车键的使用
<EditText
android:id="@+id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="text1" />
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:text="Button"/>
et.setOnKeyListener(this);
…
public boolean onKey(View view, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_ENTER) {
btn.setText(et.getText());
et.setVisibility(View.GONE);
btn.setVisibility(View.VISIBLE);
}
return true;
}
输入特定字符
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:password="true"
android:digits="01234" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:digits="abcd" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="number"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:numeric="decimal|signed"/>