Search in sources :

Example 86 with EditText

use of android.widget.EditText in project robolectric by robolectric.

the class ShadowEditTextTest method givenInitializingWithAttributeSet_whenMaxLengthDefined_thenRestrictTextLengthToMaxLength.

@Test
public void givenInitializingWithAttributeSet_whenMaxLengthDefined_thenRestrictTextLengthToMaxLength() {
    int maxLength = anyInteger();
    AttributeSet attrs = Robolectric.buildAttributeSet().addAttribute(android.R.attr.maxLength, maxLength + "").build();
    EditText editText = new EditText(RuntimeEnvironment.application, attrs);
    String excessiveInput = stringOfLength(maxLength * 2);
    editText.setText(excessiveInput);
    assertThat((CharSequence) editText.getText().toString()).isEqualTo(excessiveInput.subSequence(0, maxLength));
}
Also used : EditText(android.widget.EditText) AttributeSet(android.util.AttributeSet) Test(org.junit.Test)

Example 87 with EditText

use of android.widget.EditText in project robolectric by robolectric.

the class ShadowEditTextTest method shouldGetHintFromXml.

@Test
public void shouldGetHintFromXml() {
    Context context = RuntimeEnvironment.application;
    LayoutInflater inflater = LayoutInflater.from(context);
    EditText editText = (EditText) inflater.inflate(R.layout.edit_text, null);
    assertThat(editText.getHint().toString()).isEqualTo("Hello, Hint");
}
Also used : Context(android.content.Context) EditText(android.widget.EditText) LayoutInflater(android.view.LayoutInflater) Test(org.junit.Test)

Example 88 with EditText

use of android.widget.EditText in project robolectric by robolectric.

the class ShadowEditTextTest method givenInitializingWithAttributeSet_whenMaxLengthNotDefined_thenTextLengthShouldHaveNoRestrictions.

@Test
public void givenInitializingWithAttributeSet_whenMaxLengthNotDefined_thenTextLengthShouldHaveNoRestrictions() {
    AttributeSet attrs = Robolectric.buildAttributeSet().build();
    EditText editText = new EditText(RuntimeEnvironment.application, attrs);
    String input = anyString();
    editText.setText(input);
    assertThat(editText.getText().toString()).isEqualTo(input);
}
Also used : EditText(android.widget.EditText) AttributeSet(android.util.AttributeSet) Test(org.junit.Test)

Example 89 with EditText

use of android.widget.EditText in project robolectric by robolectric.

the class ShadowEditTextTest method setup.

@Before
public void setup() {
    AttributeSet attributeSet = Robolectric.buildAttributeSet().addAttribute(android.R.attr.maxLength, "5").build();
    editText = new EditText(application, attributeSet);
}
Also used : EditText(android.widget.EditText) AttributeSet(android.util.AttributeSet) Before(org.junit.Before)

Example 90 with EditText

use of android.widget.EditText in project mobile-android by photo.

the class TagsFragment method init.

public void init(View v) {
    final EditText search = (EditText) v.findViewById(R.id.edit_search);
    search.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (event != null) {
                switch(event.getKeyCode()) {
                    case KeyEvent.KEYCODE_ENTER:
                        CommonUtils.debug(TAG, "Key code enter");
                        if (KeyEvent.ACTION_DOWN == event.getAction()) {
                            CommonUtils.debug(TAG, "Opening gallery");
                            search.post(new Runnable() {

                                @Override
                                public void run() {
                                    galleryOpenControl.openGallery(search.getText().toString().trim(), null);
                                }
                            });
                            return true;
                        }
                        break;
                }
            }
            return false;
        }
    });
    Button filterBtn = (Button) v.findViewById(R.id.filterBtn);
    filterBtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            TrackerUtils.trackButtonClickEvent("filterBtn", TagsFragment.this);
            galleryOpenControl.openGallery(mAdapter.getSelectedTags(), null);
        }
    });
    refresh(v);
}
Also used : EditText(android.widget.EditText) KeyEvent(android.view.KeyEvent) Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) OnEditorActionListener(android.widget.TextView.OnEditorActionListener) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) ListView(android.widget.ListView)

Aggregations

EditText (android.widget.EditText)655 View (android.view.View)309 TextView (android.widget.TextView)220 DialogInterface (android.content.DialogInterface)143 AlertDialog (android.app.AlertDialog)126 Button (android.widget.Button)126 Intent (android.content.Intent)99 LinearLayout (android.widget.LinearLayout)79 ImageView (android.widget.ImageView)61 AlertDialog (android.support.v7.app.AlertDialog)54 ScrollView (android.widget.ScrollView)52 LayoutInflater (android.view.LayoutInflater)48 AdapterView (android.widget.AdapterView)46 ViewGroup (android.view.ViewGroup)42 Editable (android.text.Editable)41 Context (android.content.Context)40 RecyclerView (android.support.v7.widget.RecyclerView)40 ListView (android.widget.ListView)39 Dialog (android.app.Dialog)36 Bundle (android.os.Bundle)36