Thursday, 23 August 2018

Xamarin Layout Movement

RANGE INPUT GENERATORXamarin Layout moment is a technique to move one interface to another interface.For example , user is login the system and after the login the user will get the homepage.Login and home page are separate interface.Application need to move from Login interface to homepage interface.




                
Xamarin application ,first gives the user the login layout, after the login has been verified ,the users will get home page layout. This is done by use intent and start activity.An activity of instant is created and the call start activity.Here we have two activity , we have to move between activity.
                       

This is the code , how and layout movement is done with start activity.  


  Android.Content.Intent i = new Android.Content.Intent(this, typeof(HomePage_Activity));
  StartActivity(i);

Please keep in the mind that you have to set content view for a particular activity at oncreate  method.Here is the full code.


using Android.App;
using Android.Widget;
using Android.OS;
using Android.Support.V7.App;

namespace App5
{
       [Activity(Label = "@string/app_name", Theme = "@style/AppTheme", MainLauncher = true)]
                 public class LoginActivity : AppCompatActivity
                 {
                    protected override void OnCreate(Bundle savedInstanceState)
                      {
                             base.OnCreate(savedInstanceState);
                             SetContentView(Resource.Layout.activity_main);

                                Android.Content.Intent i = new Android.Content.Intent(this, typeof(HomePage_Activity));
                              StartActivity(i);
                         }
                }
}



               Another aspect of this movement is , passing data.Activity need to pass some data to next
Activity. 

              For example , we are doing login, next we are going to the home page .The login page will pass homepage Activity about logged in user information ,so that home page can display particular user information. Putextra is a method  that can pass an extra value when we are moving to activity.



  Android.Content.Intent i = new Android.Content.Intent(this, typeof(HomePage_Activity));
 i.PutExtra("SessionID", "Your Session value");
  StartActivity(i);




Now , how homepage will receive the additional data sent by the login page. GetStringExtra method helps to retrieve the data.


 
string sessionid = Intent.GetStringExtra("SessionID") ?? "";


No comments:

Post a Comment

বাঙালির বেড়ানো সেরা চারটি ঠিকানা

  বাঙালি মানে ঘোড়া পাগল | দু একদিন ছুটি পেলো মানে বাঙালি চলল ঘুরতে | সে সমুদ্রই হোক , পাহাড়ি হোক বা নদী হোক। বাঙালির ...