Skip to main content


Showing posts with the label AndroidStudio

Simple Photo Gallery List Fragment in Android Studio

1 IntroductionThis guide will specifically be covering "SimplePhotoGalleryListFragment."
2 AsyncTaskLoaders and Fragments Loading our entire image gallery into a list in Android Studio is an intensive task. As a result, we want to make use of an Android construct called an AsyncTaskLoader
Fragments provide a special interface for automatically kick starting and interacting with async task loaders. In our gallery list fragment:
@Override publicvoidonCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);// Create an empty loader and pre-initialize the photo list items as an empty list. Context context =getActivity().getBaseContext();// Set up empty mAdapter mPhotoListItem =newArrayList(); mAdapter =newPhotoAdapter(context, R.layout.photo_item, mPhotoListItem,false);// Prepare the loader. Either re-connect with an existing one, // or start a new one. getLoaderManager().initLoader(0, null,this);}

Fragment in Android Studio

1 Getting Started Open Android Studio and click "File -> New Project." You should see the new project wizard open up. Name your app "FragmentExample."
Before we go too far, I wanted to point out the "Support Mode" options near the bottom of the new project wizard. If you plan on using fragments in combination with Pre-Honeycomb devices you will need to use these to ensure backward compatibility with fragments.

As you can see, Android Studio will automatically generate a starting Fragment for you. However, since we are learning about using fragments we are going to create and modify our own custom fragment.
2 What is a Fragment in Android Studio?
In Android, a Fragment is a class which represents a "behavior or portion of user interface within an Activity." Fragments were introduced to help produce UI which can adapt to various device orientations as well as function seamlessly across phones and tablets. You can even use multiple fragments with…

What is Gradle ?

Gradle is a project automation tool that builds upon the concepts of Apache Ant and Apache Maven and introduces a Groovy-based domain-specific language (DSL) instead of the more traditional XML form of declaring the project configuration.
Unlike Apache Maven, which defines lifecycles, and Apache Ant, where targets are invoked based upon a depends-on partial ordering, Gradle uses a directed acyclic graph ("DAG") to determine the order in which tasks can be run.
Gradle was designed for multi-project builds which can grow to be quite large, and supports incremental builds by intelligently determining which parts of the build tree are up-to-date, so that any task dependent upon those parts will not need to be re-executed.
The initial plugins are primarily focused around JavaGroovy and Scala development and deployment, but more languages and project workflows are on the roadmap.

Creating new Project in Android Studio

Step 1: Create a New ProjectIf you didn't have a project opened, Android Studio shows the Welcome screen. To create a new project, click New Project. If you had a project opened, Android Studio shows the development environment. To create a new project, click File >New Project. The next window lets you configure the name of your app, the package name, and the location of your project.
Enter the values for your project and click Next. Step 2: Select Form Factors and API LevelThe next window lets you select the form factors supported by your app, such as phone, tablet, TV, Wear, and Google Glass. For each form factor, you can also select the API Level that your app requires. To get more information, click Help me choose.
The API Level window shows the distribution of mobile devices running each version of Android, as shown in Figure 2. Click on an API level to see a list of features introduced in the corresponding version of Android. This helps you choose the minimum API Level that ha…

What is Android Studio ?

Android Studio is an integrated development environment (IDE) for the Android platform.It was announced on May 16, 2013 at the Google I/O conference by Google's Product Manager, Ellie Powers.Android Studio is freely available under the Apache License 2.0. Android Studio was in early access preview stage starting from version 0.1 in May 2013, then entered beta stage starting from version 0.8 which was released in June 2014. The first stable build was released in December 2014, starting from version 1.0.Based onJetBrainsIntelliJ IDEA software, the Studio is designed specifically for Android development.It is available for download on WindowsMac OS X and Linux.