Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class VehicleInfoActivity extends Activity {
- private EditText mLicence;
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_vehicle_info);
- mLicence = (EditText) findViewById(R.id.licensePlate);
- mLicence.addTextChangedListener(new TextWatcher() {
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
- }
- @Override
- public void onTextChanged(CharSequence s, int start, int before, int count) {
- }
- @Override
- public void afterTextChanged(Editable s) {
- String pattern = "X000XX000";
- if (text.length() < pattern.length() && pattern.charAt(text.length()) == '0') {
- mLicence.setInputType(InputType.TYPE_CLASS_PHONE);
- } else {
- mLicence.setInputType(InputType.TYPE_CLASS_TEXT);
- }
- }
- });
- }
- }
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- tools:context=".activities.VehicleInfoActivity">
- <EditText
- android:id="@+id/licensePlate"
- android:layout_width="150pt"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_alignParentStart="true"
- />
- </RelativeLayout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement