Search in sources :

Example 51 with EditText

use of android.widget.EditText in project coursera-android by aporter.

the class RelativeLayoutActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    final EditText textEntry = (EditText) findViewById(R.id.entry);
    final Button cancelButton = (Button) findViewById(R.id.cancel_button);
    cancelButton.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            // Clear the textEntry
            textEntry.setText("");
        }
    });
    final Button okButton = (Button) findViewById(R.id.ok_button);
    okButton.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            // Finish the application
            RelativeLayoutActivity.this.finish();
        }
    });
}
Also used : EditText(android.widget.EditText) Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) View(android.view.View)

Example 52 with EditText

use of android.widget.EditText in project coursera-android by aporter.

the class SamplerActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    // 
    final ImageButton button = (ImageButton) findViewById(R.id.button);
    button.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            // Show Toast message 
            Toast.makeText(SamplerActivity.this, "Beep Bop", Toast.LENGTH_SHORT).show();
        }
    });
    final EditText edittext = (EditText) findViewById(R.id.edittext);
    edittext.setOnKeyListener(new OnKeyListener() {

        public boolean onKey(View v, int keyCode, KeyEvent event) {
            // If the event is a key-down event on the "Done" button
            if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                // Show Toast message 
                Toast.makeText(SamplerActivity.this, edittext.getText(), Toast.LENGTH_SHORT).show();
                return true;
            }
            return false;
        }
    });
    final CheckBox checkbox = (CheckBox) findViewById(R.id.checkbox);
    checkbox.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            // Show Toast message indicating the CheckBox's Checked state
            if (((CheckBox) v).isChecked()) {
                Toast.makeText(SamplerActivity.this, "CheckBox checked", Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(SamplerActivity.this, "CheckBox not checked", Toast.LENGTH_SHORT).show();
            }
        }
    });
    final RadioButton radio_red = (RadioButton) findViewById(R.id.radio_red);
    final RadioButton radio_blue = (RadioButton) findViewById(R.id.radio_blue);
    radio_red.setOnClickListener(radio_listener);
    radio_blue.setOnClickListener(radio_listener);
    final ToggleButton togglebutton = (ToggleButton) findViewById(R.id.togglebutton);
    togglebutton.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            // Perform action on clicks
            if (togglebutton.isChecked()) {
                Toast.makeText(SamplerActivity.this, "ToggleButton checked", Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(SamplerActivity.this, "ToggleButton not checked", Toast.LENGTH_SHORT).show();
            }
        }
    });
    final RatingBar ratingbar = (RatingBar) findViewById(R.id.ratingbar);
    ratingbar.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {

        public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
            Toast.makeText(SamplerActivity.this, "New Rating: " + rating, Toast.LENGTH_SHORT).show();
        }
    });
}
Also used : EditText(android.widget.EditText) ToggleButton(android.widget.ToggleButton) OnRatingBarChangeListener(android.widget.RatingBar.OnRatingBarChangeListener) RadioButton(android.widget.RadioButton) View(android.view.View) RatingBar(android.widget.RatingBar) KeyEvent(android.view.KeyEvent) ImageButton(android.widget.ImageButton) CheckBox(android.widget.CheckBox) OnClickListener(android.view.View.OnClickListener) OnKeyListener(android.view.View.OnKeyListener)

Example 53 with EditText

use of android.widget.EditText in project agera by google.

the class NotesFragment method onCreateView.

@Nullable
@Override
public View onCreateView(final LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable final Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.notes_fragment, container, false);
    // Find the clear button and wire the click listener to call the clear notes updatable
    view.findViewById(R.id.clear).setOnClickListener(v -> notesStore.clearNotes());
    // Find the add button and wire the click listener to show a dialog that in turn calls the add
    // note from text from the notes store when adding notes
    view.findViewById(R.id.add).setOnClickListener(v -> {
        final EditText editText = new EditText(v.getContext());
        editText.setId(R.id.edit);
        new AlertDialog.Builder(v.getContext()).setTitle(R.string.add_note).setView(editText).setPositiveButton(R.string.add, (d, i) -> {
            notesStore.insertNoteFromText(editText.getText().toString());
        }).create().show();
    });
    // Setup the recycler view using the repository adapter
    recyclerView = (RecyclerView) view.findViewById(R.id.result);
    recyclerView.setAdapter(adapter);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    final ImageView imageView = (ImageView) view.findViewById(R.id.background);
    updatable = () -> backgroundRepository.get().ifSucceededSendTo(imageView::setImageBitmap);
    return view;
}
Also used : EditText(android.widget.EditText) AlertDialog(android.app.AlertDialog) ImageView(android.widget.ImageView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) Nullable(android.support.annotation.Nullable)

Example 54 with EditText

use of android.widget.EditText in project agera by google.

the class NotesFragment method onCreate.

@Override
public void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRetainInstance(true);
    notesStore = notesStore(getContext().getApplicationContext());
    pool = new RecycledViewPool();
    final RowHandler<NoteGroup, List<Note>> rowHandler = rowBinder(pool, (r) -> new LinearLayoutManager(getContext(), HORIZONTAL, false), NoteGroup::getId, NoteGroup::getNotes, (r) -> dataBindingRepositoryPresenterOf(Note.class).layout(R.layout.text_layout).itemId(BR.note).handler(BR.click, (Receiver<Note>) (note) -> {
        final EditText editText = new EditText(getContext());
        editText.setId(R.id.edit);
        editText.setText(note.getNote());
        new AlertDialog.Builder(getContext()).setTitle(R.string.edit_note).setView(editText).setPositiveButton(R.string.edit, (d, i) -> notesStore.updateNote(note, editText.getText().toString())).create().show();
    }).handler(BR.longClick, (Receiver<Note>) notesStore::deleteNote).stableIdForItem(Note::getId).forList());
    adapter = repositoryAdapter().addLayout(layout(R.layout.header)).add(notesStore.getNotesRepository(), repositoryPresenterOf(NoteGroup.class).layout(R.layout.note_group_layout).stableIdForItem(NoteGroup::getId).bindWith(rowHandler).recycleWith(rowHandler).forList()).addItem(getInstance().format(new Date()), dataBindingRepositoryPresenterOf(String.class).layout(R.layout.footer).itemId(BR.string).forItem()).build();
    adapter.setHasStableIds(true);
    final DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
    backgroundRepository = repositoryWithInitialValue(Result.<Bitmap>absent()).observe().onUpdatesPerLoop().goTo(networkExecutor).getFrom(() -> "http://www.gravatar.com/avatar/4df6f4fe5976df17deeea19443d4429d?s=" + Math.max(displayMetrics.heightPixels, displayMetrics.widthPixels)).transform(url -> httpGetRequest(url).compile()).attemptTransform(httpFunction()).orEnd(Result::failure).goTo(calculationExecutor).thenTransform(input -> {
        final byte[] body = input.getBody();
        return absentIfNull(decodeByteArray(body, 0, body.length));
    }).onDeactivation(SEND_INTERRUPT).compile();
}
Also used : Bundle(android.os.Bundle) RepositoryAdapter.repositoryAdapter(com.google.android.agera.rvadapter.RepositoryAdapter.repositoryAdapter) Date(java.util.Date) HttpFunctions.httpFunction(com.google.android.agera.net.HttpFunctions.httpFunction) LayoutPresenters.layout(com.google.android.agera.rvadapter.LayoutPresenters.layout) ImageView(android.widget.ImageView) Result(com.google.android.agera.Result) Repository(com.google.android.agera.Repository) RecycledViewPool(android.support.v7.widget.RecyclerView.RecycledViewPool) NotesStore.notesStore(com.google.android.agera.testapp.NotesStore.notesStore) RowHandler.rowBinder(com.google.android.agera.testapp.RowHandler.rowBinder) Result.absentIfNull(com.google.android.agera.Result.absentIfNull) DateFormat.getInstance(java.text.DateFormat.getInstance) View(android.view.View) Updatable(com.google.android.agera.Updatable) RepositoryAdapter(com.google.android.agera.rvadapter.RepositoryAdapter) Receiver(com.google.android.agera.Receiver) Executor(java.util.concurrent.Executor) DataBindingRepositoryPresenters.dataBindingRepositoryPresenterOf(com.google.android.agera.rvdatabinding.DataBindingRepositoryPresenters.dataBindingRepositoryPresenterOf) LayoutInflater(android.view.LayoutInflater) Fragment(android.support.v4.app.Fragment) Executors.newSingleThreadExecutor(java.util.concurrent.Executors.newSingleThreadExecutor) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Repositories.repositoryWithInitialValue(com.google.android.agera.Repositories.repositoryWithInitialValue) DisplayMetrics(android.util.DisplayMetrics) ViewGroup(android.view.ViewGroup) RepositoryPresenters.repositoryPresenterOf(com.google.android.agera.rvadapter.RepositoryPresenters.repositoryPresenterOf) AlertDialog(android.app.AlertDialog) RecyclerView(android.support.v7.widget.RecyclerView) List(java.util.List) BitmapFactory.decodeByteArray(android.graphics.BitmapFactory.decodeByteArray) Bitmap(android.graphics.Bitmap) SEND_INTERRUPT(com.google.android.agera.RepositoryConfig.SEND_INTERRUPT) HttpRequests.httpGetRequest(com.google.android.agera.net.HttpRequests.httpGetRequest) Nullable(android.support.annotation.Nullable) HORIZONTAL(android.support.v7.widget.LinearLayoutManager.HORIZONTAL) EditText(android.widget.EditText) EditText(android.widget.EditText) Receiver(com.google.android.agera.Receiver) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DisplayMetrics(android.util.DisplayMetrics) Date(java.util.Date) RecycledViewPool(android.support.v7.widget.RecyclerView.RecycledViewPool) List(java.util.List) NotesStore.notesStore(com.google.android.agera.testapp.NotesStore.notesStore)

Example 55 with EditText

use of android.widget.EditText in project FirebaseUI-Android by firebase.

the class RegisterEmailActivityTest method testSignUpButton_successfulRegistrationShouldContinueToSaveCredentials.

@Test
@Config(shadows = { BaseHelperShadow.class, ActivityHelperShadow.class })
public void testSignUpButton_successfulRegistrationShouldContinueToSaveCredentials() {
    // init mocks
    new BaseHelperShadow();
    reset(BaseHelperShadow.sSaveSmartLock);
    TestHelper.initializeApp(RuntimeEnvironment.application);
    RegisterEmailActivity registerEmailActivity = createActivity();
    // Trigger new user UI (bypassing check email)
    registerEmailActivity.onNewUser(new User.Builder(TestConstants.EMAIL).setName(TestConstants.NAME).setPhotoUri(TestConstants.PHOTO_URI).build());
    EditText name = (EditText) registerEmailActivity.findViewById(R.id.name);
    EditText password = (EditText) registerEmailActivity.findViewById(R.id.password);
    name.setText(TestConstants.NAME);
    password.setText(TestConstants.PASSWORD);
    FirebaseUser mockFirebaseUser = Mockito.mock(FirebaseUser.class);
    when(mockFirebaseUser.getEmail()).thenReturn(TestConstants.EMAIL);
    when(mockFirebaseUser.getDisplayName()).thenReturn(TestConstants.NAME);
    when(mockFirebaseUser.getPhotoUrl()).thenReturn(TestConstants.PHOTO_URI);
    when(mockFirebaseUser.updateProfile((UserProfileChangeRequest) Mockito.any())).thenReturn(new AutoCompleteTask<Void>(null, true, null));
    when(BaseHelperShadow.sFirebaseAuth.createUserWithEmailAndPassword(TestConstants.EMAIL, TestConstants.PASSWORD)).thenReturn(new AutoCompleteTask<AuthResult>(new FakeAuthResult(mockFirebaseUser), true, null));
    Button button = (Button) registerEmailActivity.findViewById(R.id.button_create);
    button.performClick();
    TestHelper.verifySmartLockSave(EmailAuthProvider.PROVIDER_ID, TestConstants.EMAIL, TestConstants.PASSWORD);
}
Also used : EditText(android.widget.EditText) Button(android.widget.Button) BaseHelperShadow(com.firebase.ui.auth.testhelpers.BaseHelperShadow) FakeAuthResult(com.firebase.ui.auth.testhelpers.FakeAuthResult) AuthResult(com.google.firebase.auth.AuthResult) FirebaseUser(com.google.firebase.auth.FirebaseUser) FakeAuthResult(com.firebase.ui.auth.testhelpers.FakeAuthResult) Test(org.junit.Test) Config(org.robolectric.annotation.Config) BuildConfig(com.firebase.ui.auth.BuildConfig)

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