Skip to content

Instantly share code, notes, and snippets.

@gavilanch
Created August 13, 2017 14:06
Show Gist options
  • Save gavilanch/0f0c7f80ca759aa0ec1351e84a3d892d to your computer and use it in GitHub Desktop.
Save gavilanch/0f0c7f80ca759aa0ec1351e84a3d892d to your computer and use it in GitHub Desktop.
// En MainActivity.cs
[Activity(Label = "NotiXamarin_ensayo", Icon = "@drawable/icon", ParentActivity = typeof(NewsListActivity))]
public class MainActivity : Activity
{
internal static string KEY_ID = "KEY_ID";
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
// var id = Intent.Extras.GetInt(KEY_ID);
PrepareActionBar();
var newsService = new NewsService();
var news = newsService.GetNewsById(1);
var newsImageExample = GetDrawable(Resource.Drawable.Icon);
var newsTitle = FindViewById<TextView>(Resource.Id.newsTitle);
var newsBody = FindViewById<TextView>(Resource.Id.newsBody);
var newsImage = FindViewById<ImageView>(Resource.Id.newsImage);
var display = WindowManager.DefaultDisplay;
Android.Graphics.Point point = new Android.Graphics.Point();
display.GetSize(point);
var imageURL = string.Concat(ValuesService.ImagesBaseURL, news.ImageName);
Picasso.With(ApplicationContext)
.Load(imageURL)
.Resize(point.X, 0)
.Into(newsImage);
newsTitle.Text = news.Title;
newsBody.Text = news.Body;
}
private void PrepareActionBar()
{
ActionBar.SetDisplayHomeAsUpEnabled(true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment