本文整理汇总了C#中EditText.SetText方法的典型用法代码示例。如果您正苦于以下问题:C# EditText.SetText方法的具体用法?C# EditText.SetText怎么用?C# EditText.SetText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EditText
的用法示例。
在下文中一共展示了EditText.SetText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCreateView
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
fa = base.Activity;
ll = (RelativeLayout)inflater.Inflate(Resource.Layout.ReportCruelty, container, false);
//CrueltyNavMenuHelper.InitCrueltyNavMenu (this, CrueltyNavMenuItem.ReportIt);
_crueltyReport = ((AfaApplication)fa.ApplicationContext).CrueltyReport;
if (_crueltyReport == null)
{
_crueltyReport = new CrueltyReport();
((AfaApplication)fa.ApplicationContext).CrueltyReport = _crueltyReport;
}
_locationInput = ll.FindViewById<EditText>(Resource.Id.LocationInput);
_crueltyTypeInput = ll.FindViewById<EditText>(Resource.Id.TypeOfCrueltyInput);
if (_crueltyReport.PlaceSpecified)
{
var locationText = new StringBuilder();
locationText.Append("<font color='#D34C96'><b>");
locationText.Append(_crueltyReport.PlaceName);
locationText.Append("</b></font>");
locationText.Append("<br />");
locationText.Append("<font color='#B5B5B5'><small>");
locationText.Append(_crueltyReport.PlaceFormattedShortAddress);
locationText.Append("</small></font>");
var htmlText = locationText.ToString();
_locationInput.SetText(Html.FromHtml(htmlText), TextView.BufferType.Spannable);
}
_crueltyTypeInput.Text = _crueltyReport.CrueltyType != null ? _crueltyReport.CrueltyType.Name : null;
//_locationInput.FocusChange += (sender, args) =>
//{
// if (args.HasFocus) {
// var intent = new Intent (fa, typeof(NearbyPlacesActivity));
// StartActivity (intent);
// }
//};
_locationInput.Click += (sender, args) =>
{
var intent = new Intent(fa, typeof(NearbyPlacesActivity));
StartActivity(intent);
};
//_crueltyTypeInput.FocusChange += (sender, args) =>
//{
// if (args.HasFocus) {
// var intent = new Intent (fa, typeof(CrueltyTypesActivity));
// StartActivity (intent);
// }
//};
_crueltyTypeInput.Click += (sender, args) =>
{
var intent = new Intent(fa, typeof(CrueltyTypesActivity));
StartActivity(intent);
};
//// ToDo: This line hides the soft keyboard, but doing so makes the EditText only have 1 line.
//// Look into alternative
////_locationInput.InputType = InputTypes.Null;
//_crueltyTypeInput.InputType = InputTypes.Null;
_submitButton = ll.FindViewById<Button>(Resource.Id.SubmitButton);
_submitButton.Enabled = _crueltyReport.PlaceSpecified && _crueltyReport.CrueltyTypeSpecified;
_submitButton.Click +=
(sender, args) =>
{
// Create a new Cruelty Spot
_loadingDialog = DialogManager.ShowSubmittingDialog(fa);
//CrueltySpotDto newCrueltySpot;
CrueltySpot newCrueltySpot;
if (_crueltyReport.IsGooglePlace())
{
// Fetch details from google
var googlePlaces = new GooglePlacesApi.GooglePlaces(AfaConfig.GoogleApiKey);
googlePlaces.GetDetails(_crueltyReport.GooglePlace.Reference, response =>
{
// ToDo: Check Status and handle non-OK
var placeDetails = response.result;
var latitude = placeDetails.geometry.location.lat;
var longitude = placeDetails.geometry.location.lng;
newCrueltySpot = new CrueltySpot
{
Name = placeDetails.name,
//Description = _descriptionInput.Text,
Address = placeDetails.Address,
City = placeDetails.City,
StateProvinceAbbreviation = placeDetails.StateOrProvince,
Zipcode = placeDetails.PostalCode,
PhoneNumber = placeDetails.formatted_phone_number,
WebpageUrl = placeDetails.website,
//Latitude = placeDetails.geometry.location.lat,
//Longitude = placeDetails.geometry.location.lng,
//.........这里部分代码省略.........
示例2: OnCreateView
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View v = inflater.Inflate(Resource.Layout.fragment_crime, container, false);
if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb) {
// Using ParentActivity and NavUtils causes OnCreate to be called again
// in CrimeListFragment, causing the subtitle view to be reset
// if (NavUtils.GetParentActivityName(Activity) != null) {
Activity.ActionBar.SetDisplayHomeAsUpEnabled(true);
// }
}
mTitleField = (EditText)v.FindViewById(Resource.Id.crime_title_edittext);
mTitleField.SetText(mCrime.Title, TextView.BufferType.Normal);
mTitleField.BeforeTextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
// nothing for now
};
mTitleField.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
mCrime.Title = e.Text.ToString();
mCallBacks.OnCrimeUpdated();
};
mTitleField.AfterTextChanged += (object sender, Android.Text.AfterTextChangedEventArgs e) => {
// nothing for now
};
// One DateTime Button
mDateButton = (Button)v.FindViewById(Resource.Id.crime_date_button);
mDateButton.Click += (sender, e) => {
Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(Activity);
builder.SetTitle(Resource.String.date_or_time_alert_title);
builder.SetPositiveButton(Resource.String.date_or_time_alert_date, (object date, DialogClickEventArgs de) => {
Android.Support.V4.App.FragmentManager fm = Activity.SupportFragmentManager;
DatePickerFragment dialog = DatePickerFragment.NewInstance(mCrime.Date);
dialog.SetTargetFragment(this, REQUEST_DATE);
dialog.Show(fm, CrimeFragment.DIALOG_DATE);
});
builder.SetNegativeButton(Resource.String.date_or_time_alert_time, (object time, DialogClickEventArgs de) => {
Android.Support.V4.App.FragmentManager fm = Activity.SupportFragmentManager;
TimePickerFragment dialog = TimePickerFragment.NewInstance(mCrime.Date);
dialog.SetTargetFragment(this, REQUEST_TIME);
dialog.Show(fm, CrimeFragment.DIALOG_TIME);
});
builder.Show();
};
// Separate date and time buttons
// mDateButton = (Button)v.FindViewById(Resource.Id.crime_date_button);
// mDateButton.Click += (sender, e) => {
// FragmentManager fm = Activity.SupportFragmentManager;
// DatePickerFragment dialog = DatePickerFragment.NewInstance(mCrime.Date);
// dialog.SetTargetFragment(this, REQUEST_DATE);
// dialog.Show(fm, CrimeFragment.DIALOG_DATE);
// };
//
// mTimeButton = (Button)v.FindViewById(Resource.Id.crime_time_button);
// mTimeButton.Click += (sender, e) => {
// FragmentManager fm = Activity.SupportFragmentManager;
// TimePickerFragment dialog = TimePickerFragment.NewInstance(mCrime.Date);
// dialog.SetTargetFragment(this, REQUEST_TIME);
// dialog.Show(fm, CrimeFragment.DIALOG_TIME);
// };
UpdateDateTime();
mSolvedCheckBox = (CheckBox)v.FindViewById(Resource.Id.crime_solved_checkbox);
mSolvedCheckBox.Checked = mCrime.Solved;
mSolvedCheckBox.CheckedChange += (object sender, CompoundButton.CheckedChangeEventArgs e) => {
mCrime.Solved = e.IsChecked;
mCallBacks.OnCrimeUpdated();
};
mPhotoView = v.FindViewById<ImageView>(Resource.Id.crime_imageView);
mPhotoView.Click += (object sender, EventArgs e) => {
Photo p = mCrime.Photo;
if (p == null)
return;
Android.Support.V4.App.FragmentManager fm = Activity.SupportFragmentManager;
// BNR
// string path = Activity.GetFileStreamPath(p.Filename).AbsolutePath;
if (p.Filename != null)
ImageFragment.NewInstance(p.Filename, p.GetRotation()).Show(fm, DIALOG_IMAGE);
};
mPhotoView.LongClick += (object sender, View.LongClickEventArgs e) => {
if (mCrime.Photo != null) {
AlertDialog.Builder ad = new AlertDialog.Builder(Activity);
ad.SetTitle(mCrime.Title);
ad.SetMessage("Do you really want to delete the photo evidence of this crime?");
ad.SetCancelable(true);
ad.SetPositiveButton("DELETE", delegate(object s, DialogClickEventArgs evt) {
if (File.Exists(mCrime.Photo.Filename)) {
File.Delete(mCrime.Photo.Filename);
mCrime.Photo = null;
mPhotoView.SetImageDrawable(null);
}
});
ad.SetNegativeButton("Cancel", (s, evt) => {});
ad.Show();
}
//.........这里部分代码省略.........