android學習筆記16:帶提示的輸入框

來源:互聯網
上載者:User

在需要使用者輸入資料的時候,友好的介面是非常重要的,所以如果我們能在輸入框給使用者一些提示,將能很好的提高程式的易用性,android就給我們提供了這樣一個屬性,也就是android:hint。

另外這個程式的textview裡面使用一下android中的shape屬性,可以參見我前一篇轉載的部落格。

<?xml version="1.0" encoding="utf-8"?><TableLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"android:layout_width="fill_parent"android:layout_height="fill_parent"><TableRow><TextViewandroid:layout_width="fill_parent"android:layout_height="wrap_content"android:text="使用者名稱:"android:textSize="10sp"android:background="@drawable/bg_border"/><EditText android:layout_width="fill_parent"android:layout_height="wrap_content"android:hint="請填寫登入帳號"android:selectAllOnFocus="true"/></TableRow><TableRow><TextViewandroid:layout_width="fill_parent"android:layout_height="wrap_content"android:text="密碼:"android:textSize="10pt"android:background="@drawable/bg_border"/><EditTextandroid:layout_width="fill_parent"android:layout_height="wrap_content"android:password="true"/></TableRow><TableRow><TextViewandroid:layout_width="fill_parent"android:layout_height="wrap_content"android:text="電話號碼:"android:textSize="10pt"android:background="@drawable/bg_border"/><EditTextandroid:layout_width="fill_parent"android:layout_height="wrap_content"android:hint="請填寫您的電話號碼"android:selectAllOnFocus="true"android:phoneNumber="true"/></TableRow><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="註冊"/></TableLayout>

 使用的shape檔案

<?xml version="1.0" encoding="UTF-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="#000000"/><stroke android:width="2dip" android:color="#ff0000" /></shape>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.