activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/rl" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="10dp" tools:context=".MainActivity" android:background="#d8ddf7" > <!-- android:inputType="textCapCharacters" Can be combined with text and its variations to request capitalization of all characters. Corresponds to TYPE_TEXT_FLAG_CAP_CHARACTERS. --> <EditText android:id="@+id/et" android:layout_width="250dp" android:layout_height="wrap_content" android:hint="Input your country" android:padding="10dp" android:inputType="textCapCharacters" /> <EditText android:id="@+id/et_city" android:layout_width="250dp" android:layout_height="wrap_content" android:hint="Input your City" android:padding="10dp" android:layout_below="@+id/et" /> </RelativeLayout> MainActivity.java
package com.cfsuman.me.androidcodesnippets; import android.os.Bundle; import android.app.Activity; import android.text.InputFilter; import android.widget.EditText; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Get the widgets reference from XML layout EditText et = (EditText) findViewById(R.id.et); EditText et_city = (EditText) findViewById(R.id.et_city); /* setFilters(InputFilter[] filters) Sets the list of input filters that will be used if the buffer is Editable. InputFilter.AllCaps This filter will capitalize all the lower case letters that are added through edits. */ et_city.setFilters(new InputFilter[]{new InputFilter.AllCaps()}); } }
- How to create rounded corners EditText
- How to change EditText bottom border color
- How to change EditText background color
- How to remove auto focus from EditText
- How to change EditText cursor color
- How to clear EditText
- How to disable EditText
- How to add placeholder to an EditText
- How to create a transparent EditText
- How to remove underline from EditText
Komentar
Posting Komentar