Home | History | Annotate | Download | only in widget
      1 /*
      2  * Copyright (C) 2015 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.example.android.support.design.widget;
     18 
     19 import com.example.android.support.design.R;
     20 
     21 import android.os.Bundle;
     22 import android.support.design.widget.TextInputLayout;
     23 import android.support.v7.app.AppCompatActivity;
     24 import android.view.View;
     25 
     26 /**
     27  * This demonstrates idiomatic usage of {@code TextInputLayout}
     28  */
     29 public class TextInputLayoutUsage extends AppCompatActivity {
     30 
     31     private TextInputLayout mUsernameInputLayout;
     32 
     33     @Override
     34     protected void onCreate(Bundle savedInstanceState) {
     35         super.onCreate(savedInstanceState);
     36         setContentView(R.layout.design_text_input);
     37 
     38         mUsernameInputLayout = (TextInputLayout) findViewById(R.id.input_username);
     39     }
     40 
     41     public void showError(View view) {
     42         mUsernameInputLayout.setError("Some unknown error has occurred");
     43     }
     44 
     45     public void clearError(View view) {
     46         mUsernameInputLayout.setError(null);
     47     }
     48 
     49 }
     50