本文整理汇总了C#中LinearLayout.FindViewById方法的典型用法代码示例。如果您正苦于以下问题:C# LinearLayout.FindViewById方法的具体用法?C# LinearLayout.FindViewById怎么用?C# LinearLayout.FindViewById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinearLayout
的用法示例。
在下文中一共展示了LinearLayout.FindViewById方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitViews
/// <summary>
/// 初始化
/// </summary>
private void InitViews()
{
ll_tab_bottom_server = FindViewById<LinearLayout> (Resource.Id.ll_tab_bottom_server);
ll_tab_bottom_my = FindViewById<LinearLayout> (Resource.Id.ll_tab_bottom_my);
ll_tab_bottom_finance = FindViewById<LinearLayout> (Resource.Id.ll_tab_bottom_finance);
btn_tab_bottom_server = ll_tab_bottom_server.FindViewById<ImageButton> (Resource.Id.btn_tab_bottom_server);
tv_tab_bottom_server = ll_tab_bottom_server.FindViewById<TextView> (Resource.Id.tv_tab_bottom_server);
btn_tab_bottom_finance = ll_tab_bottom_finance.FindViewById<ImageButton> (Resource.Id.btn_tab_bottom_finance);
tv_tab_bottom_finance = ll_tab_bottom_finance.FindViewById<TextView> (Resource.Id.tv_tab_bottom_finance);
btn_tab_bottom_my = ll_tab_bottom_my.FindViewById<ImageButton> (Resource.Id.btn_tab_bottom_my);
tv_tab_bottom_my = ll_tab_bottom_my.FindViewById<TextView> (Resource.Id.tv_tab_bottom_my);
//设置触发事件
ll_tab_bottom_server.SetOnClickListener (this);
ll_tab_bottom_finance.SetOnClickListener (this);
ll_tab_bottom_my.SetOnClickListener (this);
}
示例2: OnAdLoaded
public void OnAdLoaded(IAd ad)
{
Android.Util.Log.Debug (TAG, "Native Ad Loaded");
if (ad != nativeAd) {
return;
}
// Add ad into the ad container.
nativeAdContainer = FindViewById<LinearLayout> (Resource.Id.native_ad_container);
var inflater = LayoutInflater.From (this);
adView = (LinearLayout)inflater.Inflate (Resource.Layout.NativeAdView, nativeAdContainer, false);
nativeAdContainer.AddView (adView);
// Create native UI using the ad metadata.
var nativeAdIcon = adView.FindViewById<ImageView> (Resource.Id.native_ad_icon);
var nativeAdTitle = adView.FindViewById<TextView> (Resource.Id.native_ad_title);
var nativeAdBody = adView.FindViewById<TextView> (Resource.Id.native_ad_body);
var nativeAdMedia = adView.FindViewById<MediaView> (Resource.Id.native_ad_media);
var nativeAdSocialContext = adView.FindViewById<TextView> (Resource.Id.native_ad_social_context);
var nativeAdCallToAction = adView.FindViewById<Button> (Resource.Id.native_ad_call_to_action);
// Setting the Text.
nativeAdSocialContext.Text = nativeAd.AdSocialContext;
nativeAdCallToAction.Text = nativeAd.AdCallToAction;
nativeAdTitle.Text = nativeAd.AdTitle;
nativeAdBody.Text = nativeAd.AdBody;
// Downloading and setting the ad icon.
var adIcon = nativeAd.AdIcon;
NativeAd.DownloadAndDisplayImage (adIcon, nativeAdIcon);
// Download and setting the cover image.
var adCoverImage = nativeAd.AdCoverImage;
nativeAdMedia.SetNativeAd (nativeAd);
// Add adChoices icon
if (adChoicesView == null) {
adChoicesView = new AdChoicesView (this, nativeAd, true);
adView.AddView (adChoicesView, 0);
}
nativeAd.RegisterViewForInteraction (adView);
}
示例3: RetrieveEvents
//.........这里部分代码省略.........
catch(Exception e){
Console.WriteLine (e);
}
}
});
}
}
//update tap
nn_activity.RunOnUiThread(()=>{
if(showconfirmed){
adapter.ChangeListAndUpdate(confirmedcards);
}
else{
adapter.ChangeListAndUpdate(potencialcards);
}
});
nn_activity.RunOnUiThread(()=>{
if(eventcards.Count==0){
if(noeventcard!=null&&noeventcard.Parent!=null){
(noeventcard.Parent as RelativeLayout).RemoveView(noeventcard);
}
LayoutInflater inflator = LayoutInflater.From (nn_activity);
noeventcard = (LinearLayout)inflator.Inflate (Resource.Layout.raffleroot_noeventcard, null);
RelativeLayout.LayoutParams noeventcardreparam=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.WrapContent);
noeventcardreparam.AddRule(LayoutRules.Below,locationcontainerlayout.Id);
noeventcard.LayoutParameters=noeventcardreparam;
TextView hinttextview=(TextView)noeventcard.FindViewById(Resource.Id.rafflenoevent_hint_textview);
hinttextview.Text=RaffleListScreenData.NoRaffleText;
EditText charityinput=(EditText)noeventcard.FindViewById(Resource.Id.rafflenoevent_charityinput_edittext);
charityinput.Hint=RaffleListScreenData.organizationNameTextFieldPlaceholder;
EditText numberinput=(EditText)noeventcard.FindViewById(Resource.Id.rafflenoevent_phonenumber_edittext);
numberinput.Hint=RaffleListScreenData.phoneNumberTextFieldPlaceholder;
Button chritysubmitbutton=(Button)noeventcard.FindViewById(Resource.Id.rafflenoevent_charitysubmit_button);
chritysubmitbutton.Text=RaffleListScreenData.sentBtnTitle;
chritysubmitbutton.Click+= (object sender, EventArgs e) => {
//set flags
FormatCheckFlagObject[] flags=new FormatCheckFlagObject[2];
for(int i=0;i<flags.Length;i++){
string message="";
if(i==0){
message=AboutScreenData.organizationNameTextFieldPlaceholder;
}
if(i==1){
message=AboutScreenData.phoneNumberTextFieldPlaceholder;
}
}
//
if(FormatManager.chechinput(charityinput.Text,FormatManager.FormatOption.OnlyLetter)){
flags[0].flag=true;
}
if(FormatManager.chechinput(numberinput.Text,FormatManager.FormatOption.Phone)){
flags[1].flag=true;
}
bool totalfalg=true;
foreach(var flagobj in flags){
示例4: RetrieveEvents
public void RetrieveEvents()
{
if (!string.IsNullOrEmpty (GlobalVariable.currentlocation)) {
Dictionary<string,string> parameters =new Dictionary<string, string>();
parameters.Add("token_id",GlobalVariable.token_id);
App.INSTANCE.networknamager.CheckToken(parameters,(Tap5050WebResponse response)=>{
if(response.available){
var result=(Tap5050Result)response.parsedobject;
if(result.result_success.Equals("Y")){
eventlist.Clear ();
eventcards.Clear ();
Dictionary<string, string> geteventsparameters = new Dictionary<string, string> ();
geteventsparameters.Add ("location", GlobalVariable.currentlocation);
geteventsparameters.Add ("token_id", GlobalVariable.token_id);
App.INSTANCE.networknamager.GetEvents (geteventsparameters,(Tap5050WebResponse geteventsresponse)=>{
if(geteventsresponse.available){
eventlist=(List<Tap5050Event>)geteventsresponse.parsedobject;
eventlist.Sort(delegate(Tap5050Event x, Tap5050Event y){
if (x.have_contract == null || y.have_contract == null) return 0;
else if (x.have_contract.Equals("N")) return 1;
else return -1;
}
);
for(int i=0;i<eventlist.Count;i++){
EventCard eventcard =new EventCard(eventlist[i],detaltimgsmall,detaltimgoriginal);
eventcards.Add(eventcard);
}
for(int m=0;m<eventcards.Count;m++){
if(!String.IsNullOrEmpty(eventlist[m].image_url)){
App.INSTANCE.networknamager.LoadImage(new Tap5050ImageFlag(m,eventlist[m].image_url,Tap5050ImageFlag.ImageType.OrganizationImage),
(Tap5050WebResponse imgresponse)=>{
if(imgresponse.available){
var array=(byte[])imgresponse.parsedobject;
var flag=(Tap5050ImageFlag)imgresponse.flagobject;
try{
Bitmap imageBitmap= BitmapFactory.DecodeByteArray(array, 0, array.Length);
eventcards[flag.position].originalmap=Bitmap.CreateScaledBitmap (imageBitmap, TapUtil.dptodx(120), TapUtil.dptodx(120), false);
Bitmap newbitmap=Bitmap.CreateScaledBitmap (imageBitmap, TapUtil.dptodx(40), TapUtil.dptodx(40), false);
eventcards[flag.position].imagemap=newbitmap;
nn_activity.RunOnUiThread(()=>{
adapter.NotifyDataSetChanged();
});
}
catch(Exception e){
Console.WriteLine (e);
}
}
});
}
}
nn_activity.RunOnUiThread(()=>{
if(eventcards.Count==0){
if(noeventcard!=null&&noeventcard.Parent!=null){
(noeventcard.Parent as RelativeLayout).RemoveView(noeventcard);
}
LayoutInflater inflator = LayoutInflater.From (nn_activity);
noeventcard = (LinearLayout)inflator.Inflate (Resource.Layout.raffleroot_noeventcard, null);
RelativeLayout.LayoutParams noeventcardreparam=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.WrapContent);
noeventcardreparam.AddRule(LayoutRules.Below,locationcontainerlayout.Id);
noeventcard.LayoutParameters=noeventcardreparam;
TextView hinttextview=(TextView)noeventcard.FindViewById(Resource.Id.rafflenoevent_hint_textview);
hinttextview.Text=RaffleListScreenData.NoRaffleText;
EditText charityinput=(EditText)noeventcard.FindViewById(Resource.Id.rafflenoevent_charityinput_edittext);
charityinput.Hint=RaffleListScreenData.organizationNameTextFieldPlaceholder;
EditText numberinput=(EditText)noeventcard.FindViewById(Resource.Id.rafflenoevent_phonenumber_edittext);
numberinput.Hint=RaffleListScreenData.phoneNumberTextFieldPlaceholder;
Button chritysubmitbutton=(Button)noeventcard.FindViewById(Resource.Id.rafflenoevent_charitysubmit_button);
chritysubmitbutton.Text=RaffleListScreenData.sentBtnTitle;
chritysubmitbutton.Click+= (object sender, EventArgs e) => {
//set flags
FormatCheckFlagObject[] flags=new FormatCheckFlagObject[2];
for(int i=0;i<flags.Length;i++){
string message="";
if(i==0){
message=AboutScreenData.organizationNameTextFieldPlaceholder;
}
if(i==1){
message=AboutScreenData.phoneNumberTextFieldPlaceholder;
}
}
//
if(FormatManager.chechinput(charityinput.Text,FormatManager.FormatOption.OnlyLetter)){
flags[0].flag=true;
}
if(FormatManager.chechinput(numberinput.Text,FormatManager.FormatOption.Phone)){
flags[1].flag=true;
}
bool totalfalg=true;
foreach(var flagobj in flags){
if(!flagobj.flag){
totalfalg=false;
}
}
if(totalfalg){
SocialShareAndroid.Email (string.Format(RaffleListScreenData.RequestRaffleEmailBody,GlobalVariable.username,GlobalVariable.currentlocation,charityinput.Text,numberinput.Text),RaffleListScreenData.RequestRaffleEmailSubject,new string[]{RaffleListScreenData.RequestRaffleEmailTarget});
}
else{
string message="Please check:\n";
//.........这里部分代码省略.........
示例5: addMessages
private void addMessages(LinearLayout view, int containerResourceId, IEnumerable<string> messages, int itemResourceId)
{
LinearLayout container = view.FindViewById<LinearLayout>(containerResourceId);
container.RemoveAllViews();
foreach (string message in messages)
{
var messageView = _context.LayoutInflater.Inflate(itemResourceId, null);
messageView.FindViewById<TextView>(Resource.Id.MessageText).Text = message;
messageView.LongClick += (sender, args) =>
{
MessageHub.Instance.Publish(new MessageLongClickedMessage(messageView, message));
};
container.AddView(messageView);
}
}
示例6: OnCreateView
/// <inheritdoc/>
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
ZTnTrace.Trace(MethodBase.GetCurrentMethod());
var view = inflater.Inflate(Resource.Layout.GearItemEditor, container, false);
view.FindViewById<TextView>(Resource.Id.gearItemName)
.Text = D3Context.Instance.EditingItem.Name;
var editingItem = D3Context.Instance.EditingItem;
editingItem.Attributes = new ItemTextAttributes { Primary = new[] { new ItemTextAttribute { Text = Application.Context.Resources.GetString(Resource.String.EditedItem) } } };
// Attributes
layoutAttributes = view.FindViewById<LinearLayout>(Resource.Id.layoutAttributes);
layoutAttributes.FindViewById<ImageButton>(Resource.Id.add)
.Click += (sender, e) => layoutAttributes.AddView(CreateRowView(attributeLabels, AttributeFields), layoutAttributes.ChildCount - 1);
foreach (var descriptor in AttributeFields)
{
CreateAttributeRowView(descriptor);
}
// Damages
layoutItemDamage = view.FindViewById<LinearLayout>(Resource.Id.layoutItemDamage);
layoutItemDamage.FindViewById<ImageButton>(Resource.Id.add)
.Click += (sender, e) => layoutItemDamage.AddView(CreateRowView(itemDamageLabels, ItemDamageFields), layoutItemDamage.ChildCount - 1);
foreach (var descriptor in ItemDamageFields)
{
CreateItemDamageRowView(descriptor);
}
// Damage Weapons
layoutWeaponDamage = view.FindViewById<LinearLayout>(Resource.Id.layoutWeaponDamage);
layoutWeaponDamage.FindViewById<ImageButton>(Resource.Id.add)
.Click += (sender, e) => layoutWeaponDamage.AddView(CreateRowView(weaponDamageLabels, WeaponDamageFields), layoutWeaponDamage.ChildCount - 1);
foreach (var descriptor in WeaponDamageFields)
{
CreateWeaponDamageRowView(descriptor);
}
// Defense
layoutDefense = view.FindViewById<LinearLayout>(Resource.Id.layoutDefense);
layoutDefense.FindViewById<ImageButton>(Resource.Id.add)
.Click += (sender, e) => layoutDefense.AddView(CreateRowView(defenseLabels, DefenseFields), layoutDefense.ChildCount - 1);
foreach (var descriptor in DefenseFields)
{
CreateDefenseRowView(descriptor);
}
// Skills
layoutSkillBonus = view.FindViewById<LinearLayout>(Resource.Id.layoutSkillBonus);
layoutSkillBonus.FindViewById<ImageButton>(Resource.Id.add)
.Click += (sender, e) => layoutSkillBonus.AddView(CreateRowView(skillBonusLabels, SkillBonusFields), layoutSkillBonus.ChildCount - 1);
foreach (var descriptor in SkillBonusFields)
{
CreateSkillBonusRowView(descriptor);
}
// Sockets
layoutSockets = view.FindViewById<LinearLayout>(Resource.Id.layoutSockets);
layoutSockets.FindViewById<ImageButton>(Resource.Id.add)
.Click += (sender, e) => layoutSockets.AddView(CreateSocketRowView(socketLabels, KnownGems.GetGemsForItem(D3Context.Instance.EditingItem)), layoutSockets.ChildCount - 1);
var itemGems = D3Context.Instance.EditingItem.Gems;
if (itemGems != null)
{
foreach (var socketedGem in itemGems)
{
layoutSockets.AddView(CreateSocketRowView(socketLabels, KnownGems.GetGemsForItem(D3Context.Instance.EditingItem), socketedGem.Item), layoutSockets.ChildCount - 1);
}
}
return view;
}
示例7: CategoryViewHolder
public CategoryViewHolder(LinearLayout container) {
Icon = container.FindViewById<ImageView>(Resource.Id.category_icon);
Title = container.FindViewById<TextView>(Resource.Id.category_title);
}
示例8: Show
public async Task Show(TopAlert alert)
{
await Stop ();
this._Token = new CancellationTokenSource ();
this._Delay = alert.Duration;
var activity = Xamarin.Forms.Forms.Context as Android.App.Activity;
IWindowManager windowManager = Xamarin.Forms.Forms.Context.GetSystemService(Android.App.Service.WindowService).JavaCast<IWindowManager>();
this._Layout = (LinearLayout)activity.LayoutInflater.Inflate(Resource.Layout.AlertBox, null, false);
this._Layout.LayoutParameters = new ViewGroup.LayoutParams (ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
var submain = this._Layout.FindViewById<LinearLayout> (Resource.Id.linearLayout3);
submain.SetBackgroundColor (alert.BackgroundColor.ToAndroid());
var main = _Layout.FindViewById<LinearLayout> (Resource.Id.linearLayout1);
var id = Xamarin.Forms.Forms.Context.Resources.GetIdentifier ("alertborder", "drawable", Xamarin.Forms.Forms.Context.PackageName);
Android.Graphics.Drawables.GradientDrawable drawable =
Xamarin.Forms.Forms.Context.Resources.GetDrawable (id).JavaCast<Android.Graphics.Drawables.GradientDrawable>();
var text = submain.FindViewById<TextView> (Resource.Id.textView1);
text.SetTextColor (alert.TextColor.ToAndroid ());
text.Text = alert.Text;
if (alert.TextSize > 0) {
text.TextSize = alert.TextSize;
}
drawable.SetColor (alert.BorderColor.ToAndroid ());
drawable.SetCornerRadius (alert.BorderWidth);
main.SetBackground (drawable);
//activity.ActionBar.Hide ();
var actionBarHeight = activity.ActionBar.Height;
var intent = alert.Intent;
var p = new WindowManagerLayoutParams (
windowManager.DefaultDisplay.Width - intent * 2,
(alert.AlertHeight < 0 ? 200 : (int)alert.AlertHeight),
WindowManagerTypes.SystemAlert,
0 | WindowManagerFlags.NotFocusable,
Android.Graphics.Format.Translucent);
var yOffset = alert.TopOffset;
p.Gravity = GravityFlags.Top | GravityFlags.Left;
p.X = intent;
p.Y = alert.TopOffset + yOffset + (activity.ActionBar.IsShowing ? actionBarHeight : 0);
p.Height = (alert.AlertHeight < 0 ? 200 : (int)alert.AlertHeight);
windowManager.AddView (_Layout, p);
this._Layout.Touch += LayoutTouched;
Task.Run (async() => {
await Task.Delay(alert.Duration, this._Token.Token);
if (this._Token != null && this._Token.IsCancellationRequested == false)
{
if(alert.FadeOut)
{
Xamarin.Forms.Device.BeginInvokeOnMainThread( () => {
// this works
this._fadeOut = ObjectAnimator.OfFloat(_Layout, "alpha", 1f, 0f);
this._fadeOut.SetDuration(1000);
this._fadeOut.AnimationEnd += _fadeOut_AnimationEnd;
this._Set = new AnimatorSet();
this._Set.Play(_fadeOut);
this._Set.Start();
});
}
else
{
Stop();
}
}
});
}
示例9: ViewHolder
public ViewHolder(LinearLayout ll) : base(ll)
{
Layout = ll;
MenuText = ll.FindViewById<TextView>(Resource.Id.menuText);
}
示例10: SetMoneyView
private void SetMoneyView(LinearLayout layout, int value)
{
var goldShare = value < 0 ? "-" : string.Empty;
goldShare += MoneyHelper.ExtractGoldShare(value).ToString();
layout.FindViewById<TextView>(Resource.Id.Gold).Text = goldShare;
layout.FindViewById<TextView>(Resource.Id.Silver).Text = MoneyHelper.ExtractSilverShare(value).ToString();
layout.FindViewById<TextView>(Resource.Id.Copper).Text = MoneyHelper.ExtractCopperShare(value).ToString();
}
示例11: CreateMessagesUI
private void CreateMessagesUI()
{
List<UserDB> participants = new List<UserDB>();
bool moreThanOne = false, isCurrentMe = false;
if (MessageConversations.clearView)
{
listWrapper.RemoveAllViewsInLayout();
MessageConversations.clearView = false;
}
if (Contacts.SelectContactsUtil.selectedContacts.Count != 0)
Contacts.SelectContactsUtil.selectedContacts.Clear();
if (MessageConversations.currentConversationMessages [0].MessageRecipientDBList.Count > 1)
{
moreThanOne = true;
for (int m = 0; m < MessageConversations.currentConversationMessages[0].MessageRecipientDBList.Count; ++m)
{
if (MessageConversations.currentConversationMessages [0].MessageRecipientDBList [m].AccountGuid != AndroidData.CurrentUser.AccountID.ToString())
{
UserDB userDetails = dbm.GetUserWithAccountID(MessageConversations.currentConversationMessages [0].MessageRecipientDBList [m].AccountGuid);
participants.Add(userDetails);
ContactDB contact = new ContactDB();
contact.ContactUser = new LOLAccountManagement.User();
contact.ContactUser.AccountID = userDetails.AccountID;
Contacts.SelectContactsUtil.selectedContacts.Add(contact);
} else
{
UserDB userDetails = UserDB.ConvertFromUser(AndroidData.CurrentUser);
participants.Add(userDetails);
}
}
}
if (moreThanOne)
{
string toReturn = "";
List<UserDB> sortedList = new List<UserDB>();
sortedList = participants.OrderBy(s => s.LastName).OrderBy(s => s.FirstName).ToList();
foreach (UserDB eachItem in sortedList)
toReturn += string.Format("{0} {1}, ", eachItem.FirstName, eachItem.LastName);
int last = toReturn.LastIndexOf(", ");
toReturn = toReturn.Remove(last);
using (LinearLayout btnlayout = new LinearLayout (context))
{
btnlayout.Orientation = Android.Widget.Orientation.Vertical;
btnlayout.SetGravity(GravityFlags.Center);
btnlayout.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent);
btnlayout.SetPadding((int)ImageHelper.convertDpToPixel(5f, context), 0, (int)ImageHelper.convertDpToPixel(5f, context), (int)ImageHelper.convertDpToPixel(10f, context));
using (TextView name = new TextView(context))
{
name.Text = toReturn;
name.SetTextSize(Android.Util.ComplexUnitType.Dip, 18f);
name.SetTextColor(Color.Black);
RunOnUiThread(() => btnlayout.AddView(name));
}
using (Button showAll = new Button (context))
{
showAll.Gravity = GravityFlags.CenterVertical;
showAll.Text = Application.Context.Resources.GetString(Resource.String.messageShowAllInConversation);
showAll.Click += (object sender, EventArgs e) => {
showParticipants(sender, e, participants); };
showAll.SetWidth((int)ImageHelper.convertDpToPixel(180f, context));
showAll.SetHeight((int)ImageHelper.convertDpToPixel(30f, context));
showAll.SetBackgroundResource(Resource.Drawable.button);
RunOnUiThread(() => btnlayout.AddView(showAll));
}
RunOnUiThread(() => listWrapper.AddView(btnlayout));
}
}
myView = null;
LayoutInflater factory = LayoutInflater.From(this);
foreach (MessageDB message in MessageConversations.currentConversationMessages)
{
if (message != null)
{
if (!moreThanOne)
myView = factory.Inflate(Resource.Layout.lstConversation, null);
else
myView = factory.Inflate(Resource.Layout.lstConversationMulti, null);
isCurrentMe = message.FromAccountID != AndroidData.CurrentUser.AccountID ? false : true;
LinearLayout shell = new LinearLayout(context);
shell.Orientation = Orientation.Horizontal;
shell.SetGravity(GravityFlags.CenterVertical);
shell.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent);
shell.SetPadding(0, 0, 0, (int)ImageHelper.convertDpToPixel(5f, context));
RunOnUiThread(() => shell.AddView(myView));
UserDB whoAmI = new UserDB();
whoAmI = message.FromAccountID != AndroidData.CurrentUser.AccountID ? dbm.GetUserWithAccountID(message.FromAccountGuid) : UserDB.ConvertFromUser(AndroidData.CurrentUser);
ImageView userImage = shell.FindViewById<ImageView>(Resource.Id.imgProfile1);
if (Contacts.ContactsUtil.contactFilenames.Contains(message.FromAccountGuid))
//.........这里部分代码省略.........
示例12: generateUserImage
private void generateUserImage(List<UserDB>users, LinearLayout shell)
{
Bitmap blank = BitmapFactory.DecodeResource(context.Resources, Resource.Drawable.defaultuserimage);
Bitmap smallBlank = null;
byte[] img = null;
ImageView prof1, prof2, prof3, prof4;
prof1 = shell.FindViewById<ImageView>(Resource.Id.imgProfile1);
prof2 = prof3 = prof4 = null;
if (users.Count > 1)
{
smallBlank = Bitmap.CreateScaledBitmap(blank, (int)imageSize [0] / 2, (int)imageSize [0] / 2, false);
System.IO.MemoryStream ms = new System.IO.MemoryStream();
smallBlank.Compress(Bitmap.CompressFormat.Jpeg, 80, ms);
img = ms.ToArray();
prof2 = shell.FindViewById<ImageView>(Resource.Id.imgProfile2);
prof3 = shell.FindViewById<ImageView>(Resource.Id.imgProfile3);
prof4 = shell.FindViewById<ImageView>(Resource.Id.imgProfile4);
}
float imageXY = imageSize [0] / 2;
List<UserDB> newUsers = users.Where(s => s.AccountID != AndroidData.CurrentUser.AccountID && s != null).ToList();
if (newUsers.Count == 0 || (newUsers.Count == 1 && newUsers [0].Picture.Length == 0))
return;
List<byte[]> userImages = new List<byte[]>();
for (int n = 0; n < newUsers.Count; ++n)
{
if (newUsers [n].Picture.Length > 0)
{
using (Bitmap sm = BitmapFactory.DecodeByteArray(newUsers[n].Picture, 0, newUsers[n].Picture.Length))
{
using (Bitmap smScale = Bitmap.CreateScaledBitmap(sm, (int)imageXY, (int)imageXY, false))
{
using (System.IO.MemoryStream mm = new System.IO.MemoryStream())
{
smScale.Compress(Bitmap.CompressFormat.Jpeg, 80, mm);
userImages.Add(mm.ToArray());
}
}
}
} else
{
if (Contacts.ContactsUtil.contactFilenames.Contains(System.IO.Path.Combine(wowZapp.LaffOutOut.Singleton.ImageDirectory, newUsers [n].AccountGuid)))
{
using (Bitmap small = BitmapFactory.DecodeFile (System.IO.Path.Combine (wowZapp.LaffOutOut.Singleton.ImageDirectory, newUsers [n].AccountGuid)))
{
using (Bitmap smallUser = Bitmap.CreateScaledBitmap (small, (int)imageXY, (int)imageXY, false))
{
using (System.IO.MemoryStream m = new System.IO.MemoryStream ())
{
smallUser.Compress(Bitmap.CompressFormat.Jpeg, 80, m);
userImages.Add(m.ToArray());
}
}
}
} else
userImages.Add(img);
}
}
Bitmap [] bitmaps = new Bitmap[userImages.Count];
for (int n = 0; n < userImages.Count; ++n)
{
bitmaps [n] = ImageHelper.CreateUserProfileImageForDisplay(userImages [n], (int)imageXY, (int)imageXY, this.Resources);
if (bitmaps [n] == null)
bitmaps [n] = blank;
}
if (userImages.Count == 1 && users.Count == 1)
{
prof1.SetImageBitmap(bitmaps [0]);
}
int diff = users.Count - userImages.Count;
switch (userImages.Count)
{
case 2:
prof1.SetImageBitmap(bitmaps [0]);
prof2.SetImageBitmap(bitmaps [1]);
break;
case 3:
prof1.SetImageBitmap(bitmaps [0]);
prof2.SetImageBitmap(bitmaps [1]);
prof3.SetImageBitmap(bitmaps [2]);
break;
case 4:
prof1.SetImageBitmap(bitmaps [0]);
prof2.SetImageBitmap(bitmaps [1]);
prof3.SetImageBitmap(bitmaps [2]);
prof3.SetImageBitmap(bitmaps [3]);
break;
}
}
示例13: CreateUI
private void CreateUI()
{
if (MessageConversations.clearView)
{
RunOnUiThread(() => listWrapper.RemoveAllViewsInLayout());
MessageConversations.clearView = false;
}
int c = 0;
List<int> unreadMessages = new List<int>();
int numberInConversation = 0;
foreach (LOLMessageConversation conversation in MessageConversations.conversationsList)
{
unreadMessages.Add(conversation.MessageIDs.Count - conversation.ReadMessageIDs.Count);
int t = 0;
}
if (unknownUsers == null)
unknownUsers = new List<Guid>();
else
unknownUsers.Clear();
myView = null;
LayoutInflater factory = LayoutInflater.From(this);
List<Guid> unknownMessages = new List<Guid>();
foreach (MessageDB latestMessage in MessageConversations.initialMessages)
{
UserDB whoFrom = new UserDB();
whoFrom = dbm.GetUserWithAccountID(MessageConversations.conversationsList [c].Recipients [0].ToString());
if (latestMessage.MessageRecipientDBList.Count != 0)
{
if (whoFrom == null && latestMessage.MessageRecipientDBList [0].AccountGuid == AndroidData.CurrentUser.AccountID.ToString())
whoFrom = UserDB.ConvertFromUser(AndroidData.CurrentUser);
if (whoFrom != null)
{
#if DEBUG
System.Diagnostics.Debug.WriteLine("c = {0}, Recipient[0] Guid = {1}, whoFrom name = {2} {3}", c, MessageConversations.conversationsList [c].Recipients [0],
whoFrom.FirstName, whoFrom.LastName);
#endif
List<UserDB> users = new List<UserDB>();
numberInConversation = latestMessage.MessageRecipientDBList.Count;
for (int i = 0; i < (numberInConversation > 3 ? 3 : numberInConversation); ++i)
{
if (latestMessage.MessageRecipientDBList [i] != null)
{
UserDB current = dbm.GetUserWithAccountID(latestMessage.MessageRecipientDBList [i].AccountGuid.ToString());
if (current == null && latestMessage.MessageRecipientDBList [i].AccountGuid != AndroidData.CurrentUser.AccountID.ToString())
unknownUsers.Add(new Guid(latestMessage.MessageRecipientDBList [i].AccountGuid));
else
{
//users.Add (current);
if (current == null && latestMessage.MessageRecipientDBList [i].AccountGuid == AndroidData.CurrentUser.AccountID.ToString())
users.Add(UserDB.ConvertFromUser(AndroidData.CurrentUser));
else
users.Add(current);
}
}
}
UserDB sender = new UserDB();
sender = dbm.GetUserWithAccountID(latestMessage.FromAccountGuid);
if (sender == null)
sender = UserDB.ConvertFromUser(AndroidData.CurrentUser);
if (numberInConversation == 1)
myView = factory.Inflate(Resource.Layout.lstConversation, null);
else
myView = factory.Inflate(Resource.Layout.lstConversationMulti, null);
int leftOver = (int)wowZapp.LaffOutOut.Singleton.ScreenXWidth - (int)ImageHelper.convertDpToPixel(imageSize [0] + 30f, context);
LinearLayout shell = new LinearLayout(context);
shell.Orientation = Orientation.Horizontal;
shell.SetGravity(GravityFlags.CenterVertical);
shell.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent);
shell.SetPadding(0, 0, 0, (int)ImageHelper.convertDpToPixel(5f, context));
RunOnUiThread(() => shell.AddView(myView));
if (users.Count != 0)
generateUserImage(users, shell);
TextView whoAmI = shell.FindViewById<TextView>(Resource.Id.textNames);
string myName = sender.FirstName + " " + sender.LastName;
if (numberInConversation != 1)
{
myName += string.Format(" and {0} other{1}", numberInConversation == 2 ? "1" :
(numberInConversation - 1).ToString(), numberInConversation == 2 ? "." : "s.");
}
whoAmI.Text = myName;
whoAmI.SetTextSize(Android.Util.ComplexUnitType.Dip, 12f);
TextView txtMessage = shell.FindViewById<TextView>(Resource.Id.textMessageBubble);
if (latestMessage.MessageStepDBList.Count == 1 && latestMessage.MessageStepDBList [0].StepType == MessageStep.StepTypes.Text)
{
txtMessage = messageTextBox(txtMessage, latestMessage, 0, leftOver);
} else
{
for (int n = 0; n < latestMessage.MessageStepDBList.Count; ++n)
{
if (latestMessage.MessageStepDBList [n].StepType == MessageStep.StepTypes.Text)
{
//.........这里部分代码省略.........