安卓第七天
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"/>