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();
}
});
}
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();
}
});
}
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;
}
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();
}
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);
}
Aggregations