private void ButtonOnClick(object sender, EventArgs eventArgs) { Intent = new Intent(); Intent.SetType("image/*"); Intent.SetAction(Intent.ActionGetContent); StartActivityForResult(Intent.CreateChooser(Intent, "Select Picture"), PickImageId); }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); // Coloca o layout "main" dos recursos em nossa view SetContentView (Resource.Layout.Main); image_view = FindViewById<ImageView> (Resource.Id.image_view); contacts = FindViewById<ListView> (Resource.Id.contacts); // Pega o botão do recurso de layout e coloca um evento nele Button import_contacts = FindViewById<Button> (Resource.Id.import_contacts); import_contacts.Click += delegate { contacts.Visibility = ViewStates.Visible; image_view.Visibility = ViewStates.Invisible; contacts.Adapter = new ContactsAdapter(this); }; Button import_picture = FindViewById<Button> (Resource.Id.import_picture); import_picture.Click += delegate { Intent = new Intent(); Intent.SetType("image/*"); Intent.SetAction(Intent.ActionGetContent); StartActivityForResult(Intent.CreateChooser(Intent, "Escolha a Imagem"), selecionaImagem); }; Button import_camera = FindViewById<Button> (Resource.Id.import_camera); import_camera.Click += delegate { Intent intent = new Intent(MediaStore.ActionImageCapture); _file = new File (_dir, String.Format ("myPhoto_{0}.jpg", Guid.NewGuid ())); intent.PutExtra(MediaStore.ExtraOutput, Android.Net.Uri.FromFile(_file)); StartActivityForResult(intent, 0); }; }
public void OnClick(View V) { try { switch(V.Id) { case Resource.Id.bSignUp : { //CHECK VALIDATION - FOR 'RIGHT DATA/BLANK FIELD' ENTERD BY USER //STATEMENT TO VALIDATE THE EACH RECORDS Boolean blnValidate =FieldValidation(); if (blnValidate==true) { //AADING REGISTRATION DETAILS IN DATABASE. myDb.AddRecord (etname.Text, sflat, etUsername.Text, etpwd.Text, etEmail.Text, etAge.Text); etname.Text = etUsername.Text = etpwd.Text = etEmail.Text = etAge.Text = ""; var toast = Toast.MakeText (this, myDb.sqldb_message ,ToastLength.Long); toast.Show (); //WHEN SAVING SUCESSFULLY DONE CALL TO LOGIN ACTIVITY var myIntent = new Intent (this, typeof(LoginScreen)); StartActivityForResult (myIntent, 0); } break; } case Resource.Id.tvLoginLink : { //tvLoginLink.SetBackgroundColor(Color.PowderBlue); //tvLoginLink.SetShadowLayer(30, 0, 0, Color.Red); var myIntent = new Intent (this, typeof(LoginScreen)); StartActivityForResult (myIntent, 0); break; } case Resource.Id.imageview_profile : { //var myIntent = new Intent (Intent.ActionPick ,Android.Provider.MediaStore.Images.Media.ExternalContentUri); //StartActivityForResult (myIntent, SELECT_PICTURE); Intent = new Intent(); Intent.SetType("image/*"); Intent.SetAction(Intent.ActionGetContent); StartActivityForResult(Intent.CreateChooser(Intent, "Select Picture"), PickImageId); break; } } } catch (NullReferenceException ex) { var toast = Toast.MakeText (this, ex.Message ,ToastLength.Short); toast.Show (); } finally { //myDb = null; } }
private void OnPicturePreviewClicked(object sender, EventArgs e) { //start camera activity -> later version Intent = new Intent(); Intent.SetType("image/*"); Intent.SetAction(Intent.ActionGetContent); StartActivityForResult(Intent.CreateChooser(Intent, Resources.GetString(Resource.String.SelectPicture)), (int)ActivityRequestCode.PickImageActionFinished); }
public void InitializeMediaPicker() { Log.Debug ("MediaPicker","Selected image source: "+source); switch (source){ case 1: Intent = new Intent (); Intent.SetType ("image/*"); Intent.PutExtra (Intent.ExtraAllowMultiple, true); Intent.SetAction (Intent.ActionGetContent); StartActivityForResult (Intent.CreateChooser (Intent, "Select Picture"), PickImageId); break; case 2: Log.Debug ("CameraIntent","Iniciamos la cámara!"); //STARTTTTT DateTime rightnow = DateTime.Now; string fname = "/plifcap_" + rightnow.ToString ("MM-dd-yyyy_Hmmss") + ".jpg"; Log.Debug ("CameraIntent","Se crea la fecha y el filename!"); Java.IO.File folder = new Java.IO.File (Android.OS.Environment.ExternalStorageDirectory + "/PlifCam"); bool success; bool cfile=false; Java.IO.File file=null; if (!folder.Exists ()) { Log.Debug ("CameraIntent","Crea el folder!"); //aqui el folder no existe y lo creamos success=folder.Mkdir (); if (success) { Log.Debug ("CameraIntent","Sip, lo creó correctamente"); //el folder se creo correctamente! file = new Java.IO.File(Android.OS.Environment.ExternalStorageDirectory + "/PlifCam/", fname); cfile = true; }else{ //el folder no se creó, error. } } else { Log.Debug ("CameraIntent","Ya existia el folder!"); //aqui el folder si existe file = new Java.IO.File(Android.OS.Environment.ExternalStorageDirectory + "/PlifCam/", fname); cfile = true; apath=file.AbsolutePath; Log.Debug ("CameraIntent","El absolut path sería: "+apath); } if (cfile) { Log.Debug ("CameraIntent", "Si lo creó!!!"); Log.Debug ("CameraIntent","Se crea el archivo"); imgUri = Android.Net.Uri.FromFile (file); Log.Debug ("CameraIntent","se obtiene la URI del archivo"); Log.Debug ("CameraIntent","El absolut path sería: "+apath); if (imgUri == null) { Log.Debug ("CameraIntent", "ESTA NULO DX"); } else { Log.Debug ("CameraIntent","Nope, no es nulo"); } } else { Log.Debug ("CameraIntent", "Error, el archivo no se creó!!!!"); } //ENDDDDD Log.Debug ("CameraIntent", "La URI con la que se iniciara el intent es: "+imgUri); Intent intento = new Intent (Android.Provider.MediaStore.ActionImageCapture); Log.Debug ("CameraIntent",""); intento.PutExtra(Android.Provider.MediaStore.ExtraOutput, imgUri); StartActivityForResult(intento, PickCameraId); break; } }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); // Set our view from the "main" layout resource SetContentView (Resource.Layout.Add); //image code dates = FindViewById<TextView> (Resource.Id.dates); dates.Click += delegate { ShowDialog (DATE_DIALOG_ID); }; time = FindViewById<TextView> (Resource.Id.time); time.Click += delegate { ShowDialog (TIME_DIALOG_ID); }; // get the current date date = DateTime.Today; // Get the current time hour = DateTime.Now.Hour; minute = DateTime.Now.Minute; // display the current date (this method is below) UpdateDisplay (); //DB Connection //string path = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal); //SQLiteConnection dbConn = new SQLiteConnection (System.IO.Path.Combine (path, DbName)); //DB Add stuff //dbConn.CreateTable<History>(); //History newHistory = new History(); //newHistory.Date = dates.Text; //newHistory.Time = time.Text; //newHistory.Title= title.Text; //newHistory.Comment = comment.Text; //dbConn.Insert(newHistory); if (IsThereAnAppToTakePictures ()) { CreateDirectoryForPictures (); Button img = FindViewById<Button> (Resource.Id.img); iv1 = FindViewById<ImageView> (Resource.Id.iv1); img.Click += delegate { new AlertDialog.Builder (this) .SetPositiveButton ("Take a Picture", (sender, args) => { Intent intent = new Intent (MediaStore.ActionImageCapture); App._file = new File (App._dir, String.Format ("myPhoto_{0}.jpg", Guid.NewGuid ())); intent.PutExtra (MediaStore.ExtraOutput, Uri.FromFile (App._file)); StartActivityForResult (intent, 0); }) .SetNeutralButton ("Select a Picture", (sender, args) => { Intent = new Intent (); Intent.SetType ("image/*"); Intent.SetAction (Intent.ActionGetContent); StartActivityForResult (Intent.CreateChooser (Intent, "Select Picture"), PickImageId); }) .SetTitle ("Add a Picture") .Show (); }; } }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); //Find controls SetContentView(Resource.Layout.NoteEditScreen); nameTextEdit = FindViewById<EditText>(Resource.Id.NameText); descriptionTextEdit = FindViewById<EditText>(Resource.Id.NotesText); imagePreview = FindViewById<ImageView>(Resource.Id.NoteImage); saveButton = FindViewById<Button>(Resource.Id.SaveButton); pickImageButton = FindViewById<Button>(Resource.Id.PickImageButton); prioritySpinner = FindViewById<Spinner> (Resource.Id.PrioritySpinner); cancelDeleteButton = FindViewById<Button>(Resource.Id.CancelDeleteButton); dateDisplay = FindViewById<TextView> (Resource.Id.DateDisplay); timeDisplay = FindViewById<TextView> (Resource.Id.TimeDisplay); pickDate = FindViewById<Button> (Resource.Id.PickDate); pickTime = FindViewById<Button> (Resource.Id.PickTime); cancelDeleteButton.Text = Resources.GetText (Resource.String.Cancel); selectedDateTime = DateTime.Now; UpdateDisplay (); // Get note if exist int noteID = Intent.GetIntExtra("NoteID", 0); if(noteID > 0) { note = NoteItemManager.GetNote(noteID); nameTextEdit.Text = note.Name; descriptionTextEdit.Text = note.Description; prioritySpinner.SetSelection(note.Priority); cancelDeleteButton.Text = Resources.GetText (Resource.String.Delete); selectedDateTime = note.ToDoDate; selectedImageUri = note.ImageUri; selectedPriority = note.Priority; UpdateDisplay (); } //Image button pickImageButton.Click += (sender, eventArgs) => { Intent = new Intent(); Intent.SetType("image/*"); Intent.SetAction(Intent.ActionGetContent); StartActivityForResult(Intent.CreateChooser(Intent, Resources.GetText (Resource.String.SelectPicture)), PickImageId); }; //DateTime pickDate.Click += delegate { ShowDialog (PickDateId); }; pickTime.Click += delegate { ShowDialog (PickTimeId); }; //Priority spinner prioritySpinner.ItemSelected += PrioritySpinner_ItemSelected; var adapter = ArrayAdapter.CreateFromResource ( this, Resource.Array.priorities, Android.Resource.Layout.SimpleSpinnerItem); adapter.SetDropDownViewResource (Android.Resource.Layout.SimpleSpinnerDropDownItem); prioritySpinner.Adapter = adapter; //Buttons clicks cancelDeleteButton.Click += (sender, e) => CancelDelete (); saveButton.Click += (sender, e) => Save (); }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); Parse.ParseClient.Initialize("ZF2JYEfxIM7QyKVdOBn0AJEOUr1Mj5h1UMKsWqeC", "CEkjpD569RxuYtIYcJ9SNLMDt6FfL76fjJ48Qe3z"); // save = new SavingToServer (); // work = new WorkingWithFiles (); SetContentView (Resource.Layout.LoadedPhotos); Button backToMainMenu = FindViewById<Button> (Resource.Id.BackToMainMenu); backToMainMenu.Click += BackToMainMenu_Click; _imageView = FindViewById<ImageView> (Resource.Id.imageView); Intent = new Intent (); Intent.SetType ("image/*"); Intent.SetAction (Intent.ActionGetContent); StartActivityForResult (Intent.CreateChooser (Intent, "Оберіть фото"), PickImageId); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate (savedInstanceState); SetContentView (Resource.Layout.AddUser); contact_name = FindViewById<EditText> (Resource.Id.editName); contact_lastname = FindViewById<EditText> (Resource.Id.editLastName); phone = FindViewById<EditText> (Resource.Id.editPhone); add_contact = FindViewById<Button> (Resource.Id.button1); add_photo = FindViewById<ImageView> (Resource.Id.addPhoto); //action on clicking 'Add Contact' button add_contact.Click += delegate { //showing message if name field is not empty(name is required) if(contact_name.Text.Length <= 0) { Android.Widget.Toast.MakeText(this, "Name is required!", Android.Widget.ToastLength.Long).Show (); } //if name exists else { //phone number required too if(phone.Text.Length <= 0) { Android.Widget.Toast.MakeText(this, "Phone is required!", Android.Widget.ToastLength.Long).Show (); } //if all necessary fields are filled - add contact and back to Main Activity else { AddContact(add_contact_url); StartActivity(typeof(MainActivity)); } } }; //Loading image gallery on image view click add_photo.Click += delegate { Intent = new Intent(); Intent.SetType("image/*"); Intent.SetAction(Intent.ActionGetContent); StartActivityForResult(Intent.CreateChooser(Intent,"Select photo"), PickImageId); }; }