Dynamic Fragment Code Difference between Android and Xamarin

5 May

Android Code

//Get a reference to FragmentManager

FragmentManager fragment = getFragmentManager();

//call the beginTransactionMethod on FragmentManager

FragmentTransaction transaction = fragment.beginTransaction();

//call add method of FragmentTransaction

//Passing id of framelayout and the fragment that that view will hold

transaction.add(R.id.fragment_first, new FragmentFirst());

//call commit method of FragmentTransaction

transaction.commit();

 

Xamarin Code

//Begin FragmentTransaction

FragmentTransaction fragment = this.FragmentManager.BeginTransaction();

//call add method of FragmentTransaction

//Passing id of framelayout and the fragment that that view will hold

fragment.Add(Resource.Id.FragmentFirst, new FragmentFirst());

//call commit method of FragmentTransaction

fragment.Commit();

 

Remove Old Kernels

8 Dec

After updates to latest kernel files, the old kernel files does not get deleted and it wastes lots of space. To regain the space, you can delete the old kernels

Important: Keep one or two old kernels in case you can’t boot with the most recent version of kernel.

First to check the current kernel version, use this

uname -r

There are lots of ways to remove old kernel files. You can check it out in this askubuntu answer: How do i remove or hide old kernel versions to clean up the boot menu

I personally prefer deleting via the Synaptic package manager. It gives me more control of what I want to do in a grapical way.

Xubuntu – Open Whisker Menu with the Windows key

6 Nov

Menu: Settings Manager -> Keyboard -> Application Shortcuts:
xfce4-popup-whiskermenu and click the Windows Key (Super_L)

Credit: Xubuntu: Open Whisker Menu with the Windows key

Git – Create a new branch and move the uncommitted work to new branch

4 Nov

Use the following commands

git checkout -b <new-branch-name>

git add <files>

git commit

See move existing uncommitted work to a new branch in git

Git – Display the remote URL

4 Nov

To simply get the remote URL, the fastest way is

git config --get remote.origin.url

To print all remotes with fetch and push

git remote -v

To show origin remote fetch and push(slower and needs internet connection)

git remote show origin

 For more details, see How can I determine the url that a local git repo was originally cloned from

Ubuntu/VLC – Display subtitle under the video

4 Nov

See How to show subtitles under the video

Ubuntu/Xubuntu – Opening File Manager as root

4 Nov

The command for opening file manager as root is this

gksudo <filemanager-name>

In Ubuntu, the file manager is Nautilus. So for nautilus, command is

gksudo nautilus

In Xubuntu, the default file manager is Thunar. So, the command is

gksudo thunar

Xubuntu – Restart Xfce4 panel

3 Nov

On Xubuntu, in a few rare occasion, Xfce4 panel might be unresponsive. In that case, I have found that restarting Xfce4 panel is the best solution.

To restart Xfce4 panel, run this in your terminal

xfce4-panel -r

Linux/Ubuntu – Reading exfat file system

3 Nov

Exfat file system was invented by Windows. So, the exfat file system support is not default in Linux/Ubuntu.

Good news is you can enable the support for Exfat file system by installing exfat-utils package, like following

sudo apt-get install exfat-utils exfat-fuse

After that, reboot your computer

sudo reboot

This will only give read/write option, but not the ability to format exfat disk. Check how to get a drive formatted with exfat working for more details on this.

Ubuntu – Flush DNS cache

3 Nov

To flush DNS cache in Ubuntu, use the following command

sudo /etc/init.d/nscd restart
sudo /etc/init.d/dns-clean start

nscd might not be installed by default. In that case, first install nscd with the following

sudo apt-get install nscd