Edittext android studio กำหนดให ม แค แถวเด ยว

I took a 2-week hiatus from Android Studio and came back to see EditText nowhere to be found. What happened to it? Was there an update I was unaware of?

1 Answer

Edittext android studio กำหนดให ม แค แถวเด ยว

If you look in the Android Studio palette you will no longer see something named EditText. It is still there though. In the palette, select Text. You will see Plain Text, Password, etc. Add one of these to your layout by dragging and dropping it. If you then look at the code (the XML) you will see that they are EditTexts. You can see this in the component tree as well. You will notice that they each have an "android:inputType" that dictates what kind of EditText it is. Example:

รายการที่แก้ไขได้ในแอปช่วยให้ผู้ใช้ป้อนข้อความได้ แต่ละรายการที่แก้ไขได้ควรมีป้ายกำกับที่สื่อความหมายซึ่งระบุวัตถุประสงค์ของรายการ

Android มีหลายวิธีให้นักพัฒนาแอปติดป้ายกำกับ Views ในอินเทอร์เฟซผู้ใช้ของแอป สำหรับรายการที่แก้ไขได้ในอินเทอร์เฟซ วิธีติดป้ายกำกับเหล่านี้บางวิธีช่วยปรับปรุงการช่วยเหลือพิเศษได้

การใช้งาน

หากต้องการติดป้ายกำกับ TextView หรือ EditText ที่แก้ไขได้ ให้ใช้ `[android:hint](http://developer.android.com/reference/android/widget/TextView.html

attr%5Fandroid:hint)` เพื่อแสดงป้ายกำกับข้อความที่สื่อความหมายภายในรายการเมื่อรายการว่างเปล่า

<EditText

android:id="@+id/email_subject"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/email_subject_hint" />

หากอินเทอร์เฟซผู้ใช้ของแอปมีป้ายกำกับข้อความสำหรับรายการที่แก้ไขได้อยู่แล้ว ให้กำหนด `[android:labelFor](http://developer.android.com/reference/android/view/View.html

setLabelFor%28int%29) ในการติดป้ายกำกับ `View เพื่อระบุว่าป้ายกำกับอธิบายรายการใด

<LinearLayout

android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@string/email_subject_label"
    android:labelFor="@id/email_subject" />
<EditText
    android:id="@+id/email_subject"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
</LinearLayout>

เคล็ดลับ: TextInputLayout ในไลบรารีการสนับสนุนการออกแบบของ Android มีวิธีง่ายๆ ในการจัดการ EditText และป้ายกำกับข้อความที่เกี่ยวข้อง ทั้งยังทำงานร่วมกับบริการการช่วยเหลือพิเศษของ Android ได้เป็นอย่างดี

การกำหนด

<LinearLayout

android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@string/email_subject_label"
    android:labelFor="@id/email_subject" />
<EditText
    android:id="@+id/email_subject"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
</LinearLayout>

0 ใน EditText หรือ

<LinearLayout

android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@string/email_subject_label"
    android:labelFor="@id/email_subject" />
<EditText
    android:id="@+id/email_subject"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
</LinearLayout>

2 ที่แก้ไขได้อาจรบกวนความสามารถของบริการการช่วยเหลือพิเศษในการอธิบาย ไปยังส่วนต่างๆ และโต้ตอบกับข้อความที่ผู้ใช้ป้อนภายในรายการ

การออกแบบ

เมื่อผู้ใช้ไปยังรายการที่แก้ไขได้ด้วยโปรแกรมอ่านหน้าจอ อินเทอร์เฟซผู้ใช้ที่ใช้งานได้ดีจะมีองค์ประกอบต่อไปนี้

  • หากช่องที่แก้ไขได้ว่างเปล่า ช่องนั้นจะมีป้ายกำกับที่อธิบายสิ่งที่โปรแกรมอ่านหน้าจอพูด
  • หากผู้ใช้ป้อนข้อความในช่องที่แก้ไขได้ โปรแกรมอ่านหน้าจอจะพูดข้อความนั้นนอกเหนือจากป้ายกำกับที่สื่อความหมาย

เมื่อผู้ใช้ไปยังส่วนต่างๆ ในระดับที่มีความรายละเอียดน้อยลง เช่น อักขระทีละตัว โปรแกรมอ่านหน้าจอจะพูดข้อความที่ป้อน หรือคำแนะนำเมื่อไม่มีข้อความ

การทดสอบ

วิธีการตรวจสอบด้วยตนเองว่าแอปมีรายการที่แก้ไขได้ซึ่งมีการติดป้ายกำกับอย่างถูกต้องหรือไม่

  1. เปิด TalkBack
  2. ในแอป ให้ย้ายโฟกัสการช่วยเหลือพิเศษไปยังรายการที่แก้ไขได้ที่ว่างเปล่า
    • ตรวจสอบว่าคำอธิบายที่พูดของ TalkBack ของรายการที่แก้ไขได้ที่ว่างเปล่ามีป้ายกำกับหรือไม่ และตรวจสอบว่าป้ายกำกับที่สื่อความหมายนั้นตรงกับป้ายกำกับภาพในแอปหรือไม่
  3. พิมพ์ข้อความในรายการที่แก้ไขได้
  4. ย้ายโฟกัสการช่วยเหลือพิเศษไปยังรายการที่แก้ไขได้
    • หากต้องการตรวจสอบว่าคำอธิบายที่พูดมีข้อความที่คุณพิมพ์หรือไม่ ให้ฟังคำอธิบายรายการที่แก้ไขได้ของ TalkBack

เครื่องมือทดสอบอัตโนมัติของ Android สามารถตรวจจับ

<LinearLayout

android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@string/email_subject_label"
    android:labelFor="@id/email_subject" />
<EditText
    android:id="@+id/email_subject"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
</LinearLayout>

3 ที่ไม่ว่างเปล่าในรายการที่แก้ไขได้ ลองใช้เครื่องตรวจการเข้าถึงสำหรับ Android เพื่อทดสอบแอปในอุปกรณ์ด้วยตนเอง สำหรับการทดสอบอัตโนมัติ ให้เปิดการตรวจสอบการเข้าถึงใน และ