Android Newbie: Quick Solution for Fragments API
Google updates its android sdk very often. They include many things and fragment api is one of them. It is very interesting and helpful api which will let you create dynamic things. But if you are new to android you might be confused with it.
In older version of android when you create a new android project, you don’t have to deal with fragments api. But in newer version Google automatically inserts fragments api and its related code. If you don’t want this code in your program then there is one quick solution for it.
Let us create a simple Android project by
File->New->Android Application Project
Give your project a suitable name and fill all the required fields.
You can see that there is another xml file named “fragment_main.xml”. Open this file and copy all the code in this file.
Now open “activity_main.xml” file. Delete all the existing code in it. Then paste the code that you have copied from “fragment_main.xml”.
Now delete the “fragment_main.xml” file. You don’t need that now.
Now open you java file “activity_main.java”.
Delete the class named “PlaceholderFragment”. You don’t need it.
Now go to “onCreate” function and remove the if condition.
Now run your application. It will give you same output as with use of fragment api.
Hope this article will help you. If you have any question or suggestion, feel free to comment. Thanks.
In older version of android when you create a new android project, you don’t have to deal with fragments api. But in newer version Google automatically inserts fragments api and its related code. If you don’t want this code in your program then there is one quick solution for it.
Let us create a simple Android project by
File->New->Android Application Project
Give your project a suitable name and fill all the required fields.
You can see that there is another xml file named “fragment_main.xml”. Open this file and copy all the code in this file.
Now open “activity_main.xml” file. Delete all the existing code in it. Then paste the code that you have copied from “fragment_main.xml”.
Now delete the “fragment_main.xml” file. You don’t need that now.
Now open you java file “activity_main.java”.
Delete the class named “PlaceholderFragment”. You don’t need it.
Now go to “onCreate” function and remove the if condition.
Now run your application. It will give you same output as with use of fragment api.
Hope this article will help you. If you have any question or suggestion, feel free to comment. Thanks.
Tags:
Android

Muhammad Abid
Muhammad Abid is software engineer, a passionate programmer who have created many projects in C# and Java.
Get latest updates in your inbox
Popular Posts
How Yoga Nurtures Your Programming Skills
Understanding and analyzing basics of SEO
Creating SEO friendly URLs with PHP and SQL
Adobe AIR - Developing cross platform applications
Writing functions to insert, update, search, delete from SQL tables in PHP
Getting started with C#
Creating XML sitemap with PHP and SQL and submitting to search engines
Creating RSS feed in xml format with PHP and SQL
Creating thumbnails dynamically from images with PHP
Backup SQL database with PHP
Tags
CSV
Validation
Android
Java
Nashorn
PHP Mailer
cPanel
Facebook
Marketing
AdSense
Google
Technorati
Feathers
Starling
crop
PDF
Yoga
feedburner
rss feed
meta tags
SQL
backup database
Adobe Air
XML Sitemap
Syntaxhighlighter
Uploadify
Tinymce
screenshot
Text image
webmaster tools
Verifying website
web analysis
SEO
visual studio 2013
IDE