本文整理汇总了C#中Android.FindViewById方法的典型用法代码示例。如果您正苦于以下问题:C# Android.FindViewById方法的具体用法?C# Android.FindViewById怎么用?C# Android.FindViewById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android
的用法示例。
在下文中一共展示了Android.FindViewById方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetView
public override Android.Views.View GetView(int position, Android.Views.View convertView, ViewGroup parent)
{
ViewHolder holder;
if (convertView == null)
{
convertView = inflater.Inflate(Resource.Layout.PostItem, parent, false);
holder = new ViewHolder();
holder.avatar = (ImageView)convertView
.FindViewById(Resource.Id.user_photo);
holder.userNick = (TextView)convertView
.FindViewById(Resource.Id.user_nick);
holder.postDate = (TextView)convertView
.FindViewById(Resource.Id.post_date);
holder.postContent = (TextView)convertView
.FindViewById(Resource.Id.post_content);
convertView.SetTag(Resource.String.view_holder_tag, holder);
}
else
{
holder = (ViewHolder)convertView.GetTag(Resource.String.view_holder_tag);
}
Post postAtPosition = posts[position];
holder.postContent.Text = postAtPosition.content;
holder.userNick.Text = postAtPosition.userName;
holder.postDate.Text = HttpUtils.postDateToShowFormat(postAtPosition.updatedAt);
Color backgroundColor = postAtPosition.marked ? context.Resources.GetColor(Resource.Color.post_selected) : context.Resources.GetColor(Resource.Color.post_idle);
convertView.SetBackgroundColor(backgroundColor);
return convertView;
}
示例2: GetToolbarItem
public void GetToolbarItem(ToolbarItem tbi, Android.Views.View view){
int res = 0;
int imgRes = 0;
if (tbi.Icon == null) {
if (tbi.Priority == 0)
res = Resource.Id.btn_textLeft;
else
res = Resource.Id.btn_textRight;
var btn = (Android.Widget.Button)view.FindViewById(res);
btn.Text = " " + tbi.Text;
btn.TextSize = (float)Device.GetNamedSize (NamedSize.Small, typeof(Label));
btn.Visibility = Android.Views.ViewStates.Visible;
btn.SetTextColor(Color.FromHex("218DFF").ToAndroid ());
btn.Click += (sender, ee) => {
if (tbi.Command != null)
tbi.Command.Execute(tbi.CommandParameter);
};
} else {
if (tbi.Priority == 0)
res = Resource.Id.btn_imageLeft;
else
res = Resource.Id.btn_imageRight;
imgRes = Resources.GetIdentifier(tbi.Icon.File.Split('.')[0], "drawable", MainActivity.Activity.PackageName);
var imBtn = (Android.Widget.ImageButton)view.FindViewById(res);
imBtn.SetImageResource(imgRes);
imBtn.Visibility = Android.Views.ViewStates.Visible;
imBtn.Click += (sender, ee) => {
if (tbi.Command != null)
tbi.Command.Execute(tbi.CommandParameter);
};
}
}
示例3: BindUI
/// <summary>
///
/// </summary>
/// <param name="view"></param>
private void BindUI(Android.Views.View view)
{
try
{
var chart = view.FindViewById<BarChartView>(Resource.Id.barChart1);
var usageByResource = (from userDetail in UserHomeViewModel.UsageDetails
where userDetail.MeterCategory == SelectedResource.MeterId
orderby userDetail.Cost descending
group userDetail by userDetail.ResourceName into grps
select new BarModel
{
Legend = grps.Key,
Value = (float)grps.Sum(c => c.Cost),
//ValueCaptionHidden = true,
Color = Android.Graphics.Color.White
}).ToList();
view.FindViewById<TextView>(Resource.Id.selectedMeterCategory).Text = SelectedResource.MeterId;
chart.MinimumValue = 0;
chart.BarWidth = 120;
chart.BarClick += chart_BarClick;
chart.LegendHidden = true;
chart.ItemsSource = usageByResource;
}
catch (Exception ex)
{
ExceptionHandler.HandleException(ex, this.Activity);
}
}
示例4: GetView
public override Android.Views.View GetView(int position, Android.Views.View convertView, Android.Views.ViewGroup parent)
{
if (convertView == null)
{
convertView = _activity.LayoutInflater.Inflate(Resource.Layout.list_item, parent, false);
}
Product product = _products[position];
AQuery aq = new AQuery(convertView);
TextView txtProductName = convertView.FindViewById<TextView>(Resource.Id.txtProductName);
txtProductName.Text = product.Name;
Bitmap imgLoading = aq.GetCachedImage(Resource.Drawable.img_loading);
if (aq.ShouldDelay(position, convertView, parent, product.ImageUrl))
{
((AQuery)aq.Id(Resource.Id.imgProduct)).Image(imgLoading, 0.75f);
}
else
{
((AQuery)aq.Id(Resource.Id.imgProduct)).Image(product.ImageUrl, true, true, 0, 0, imgLoading, 0, 0.75f);
}
return convertView;
}
示例5: BindUI
/// <summary>
///
/// </summary>
/// <param name="view"></param>
private void BindUI(Android.Views.View view)
{
var chart = view.FindViewById<BarChartView>(Resource.Id.dailyBarChart);
var dailyUsageDetails = new List<BarModel>();
foreach(var usageDetail in UserHomeViewModel.UsageDetails)
{
var usageDate = DateTime.Parse(usageDetail.UsageEndTime);
var key = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(usageDate.Month) + "-" + usageDate.Year;
if(key == SelectedMonth.Month)
{
if (dailyUsageDetails.Any(d => d.Legend == usageDate.ToShortDateString()))
{
var existingDailyUsage = dailyUsageDetails.FirstOrDefault(d => d.Legend == usageDate.ToShortDateString());
existingDailyUsage.Value += (float)usageDetail.Cost;
}
else
{
dailyUsageDetails.Add(new BarModel()
{
Legend = usageDate.ToShortDateString(),
Value = (float)usageDetail.Cost,
Color = Android.Graphics.Color.White
//ValueCaptionHidden = true
});
}
}
}
view.FindViewById<TextView>(Resource.Id.selectedMonth).Text = SelectedMonth.Month;
chart.MinimumValue = 0;
chart.BarWidth = 120;
chart.BarClick += chart_BarClick;
chart.LegendHidden = true;
chart.ItemsSource = dailyUsageDetails;
}
示例6: OnViewCreated
public override void OnViewCreated(Android.Views.View view, Android.OS.Bundle savedInstanceState)
{
EmojiconRecentsManager.Context =view.Context;
mAdapter = new EmojiAdapter(view.Context, EmojiconRecentsManager.Recents);
GridView gridView = (GridView) view.FindViewById(Resource.Id.Emoji_GridView);
gridView.Adapter = mAdapter;
gridView.ItemClick += OnItemClick;
}
示例7: OnHeaderClick
public void OnHeaderClick(AdapterView parent, Android.Views.View view, long id)
{
string text = "Header " + ((TextView)view.FindViewById(Android.Resource.Id.Text1)).Text + " was tapped.";
if (toast == null)
{
toast = Toast.MakeText(Activity, text, ToastLength.Short);
}
else
{
toast.SetText(text);
}
toast.Show();
}
示例8: OnClick
public void OnClick(Android.Views.View v){
CheckBox checkBox =(CheckBox) v.FindViewById<CheckBox>(Resource.Id.check);
int position = int.Parse((string) v.Tag);
Items[position].Checked = checkBox.Checked;
if(checkBox.Checked){
SelectedItems.Add(Items[position]);
}
else{
SelectedItems.Remove(Items[position]);
}
ItemCheckedChanged(Items[position], checkBox.Checked);
}
示例9: OnBindView
protected override void OnBindView(Android.Views.View view)
{
base.OnBindView (view);
try {
// move our seekbar to the new view we've been given
var oldContainer = seekBar.Parent;
var newContainer = view.FindViewById<ViewGroup> (Resource.Id.seekBarPrefBarContainer);
if (oldContainer != newContainer) {
// remove the seekbar from the old view
if (oldContainer != null) {
((ViewGroup) oldContainer).RemoveView (seekBar);
}
// remove the existing seekbar (there may not be one) and add ours
newContainer.RemoveAllViews ();
newContainer.AddView (seekBar, ViewGroup.LayoutParams.FillParent,
ViewGroup.LayoutParams.WrapContent);
}
}
catch(Exception ex) {
Console.WriteLine ("Error Binding View: " + ex);
}
//if dependency is false from the beginning, disable the seek bar
if (view != null && !view.Enabled)
{
seekBar.Enabled = false;
}
UpdateView (view);
}
示例10: SetDefaultVals
private static void SetDefaultVals(Android.Views.View dialogView, bool isWorkshop)
{
now = DateTime.Now;
var currentStartDate = (startDate > DateTime.MinValue) ? startDate : now.AddMinutes(now.Minute * -1);
var currentEndDate = (endDate > DateTime.MinValue) ? endDate : now.AddDays(7).AddMinutes(now.Minute * -1);
dialogView.FindViewById<TextView>(Resource.Id.startDate).Text = currentStartDate.ToString(dateFormat);
dialogView.FindViewById<TextView>(Resource.Id.endDate).Text = currentEndDate.ToString(dateFormat);
dialogView.FindViewById<TextView>(Resource.Id.startTime).Text = currentStartDate.ToString(timeFormat);
dialogView.FindViewById<TextView>(Resource.Id.endTime).Text = currentEndDate.ToString(timeFormat);
dialogView.FindViewById<EditText>(Resource.Id.txtFilter_name).Text = name;
dialogView.FindViewById<EditText>(Resource.Id.txtFilter_name).Hint = (isWorkshop) ? "Workshop Name" : "Tutor Name";
dialogView.FindViewById<EditText>(Resource.Id.txtFilter_location).Text = location;
}
示例11: InitElements
private void InitElements(Android.Views.View view, Android.Views.LayoutInflater inflater)
{
listAdapter = new BookingsListAdapter(inflater, Resources, true);
listView = view.FindViewById<ListView>(GetListView());
listView.Adapter = listAdapter;
refresher = view.FindViewById<SwipeRefreshLayout>(Resource.Id.swipeRefresh);
refresher.Refresh += async (sender, e) =>
{
await Task.Factory.StartNew(() => LoadData(view, false, true));
NotifyListUpdate();
refresher.Refreshing = false;
};
}
示例12: BindView
public override void BindView (Android.Views.View view, Context context, ICursor cursor)
{
view.FindViewById<TextView> (Resource.Id.session_title).Text = cursor.GetString (SearchQuery.TITLE);
String snippet = cursor.GetString (SearchQuery.SEARCH_SNIPPET);
ISpannable styledSnippet = UIUtils.BuildStyledSnippet (new Java.Lang.String (snippet));
view.FindViewById<TextView> (Resource.Id.session_subtitle).TextFormatted = styledSnippet;
bool starred = cursor.GetInt (SearchQuery.STARRED) != 0;
view.FindViewById (Resource.Id.star_button).Visibility = starred ? ViewStates.Visible : ViewStates.Invisible;
}
示例13: BindView
public override void BindView (Android.Views.View view, Context context, ICursor cursor)
{
view.FindViewById<TextView> (Resource.Id.vendor_name).Text = cursor.GetString (VendorsQuery.NAME);
bool starred = cursor.GetInt (VendorsQuery.STARRED) != 0;
view.FindViewById (Resource.Id.star_button).Visibility = starred ? ViewStates.Visible : ViewStates.Invisible;
}