Skip to main content

Posts

Showing posts from 2015

Android: Login Screen using Fragments

In this tutorial, our focus is on making a User/Member login activity using fragments. With the help of Fragments we will use the same activity to show User login area and also Members Login area. Prerequisite for this tutorial: You should be know how to make an Activity And most importantly you should have prior Knowledge of Fragments. For practising basic Fragment implementation refer to Android Simple Fragment Example      We have used only three activities for this: MainActivity(which represents the Login Screen) Fragments for Members area Fragment for New Users

Android Activity Life Cycle

This is the most important and basic concept in Android. In Android, every activity has its on life cycle. An activity encountered the following methods in its life cycle. 1. onCreate() 2. onStart() 3. onResume() 4. onPause() 5. onStop() 6. onResume() 7. onDestroy()

Android : Activity

An Activity is an application component that provides a screen with which users can interact in order to do something, such as dial the phone, take a photo, send an email, or view a map. Each activity is given a window in which to draw its user interface. The window typically fills the screen, but may be smaller than the screen and float on top of other windows.[1] http://developer.android.com/guide/components/activities.html [1 ] An Activity is a screen in which user perform some task. It might be capturing image, dialing phone number, typing text message etc. These all are the activities. Almost every screen with which users interact is an activity.

Android: Create a PopUp Window Example

MainActivity.java package com.example.popupwindow; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class MainActivity extends Activity {    Button btn;

Android Simple Fragment Example

For creating a fragment we only use two things:- Fragment class Fragment xml layout In the below discussed example we need to show different fragments on button click event. So, we will be creating two layout files and two different classes. Here goes the code for first Fragment: FirstFragment.java package com.example.fragementdemo; import android.app.Fragment; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; public class FirstFragment extends Fragment {

Android App Using External font face(Custom)

Create a new Project. Make a new folder named ‘Font’ into your assets folder Paste the font file into this folder Now add the below written lines into your Java file.        textview =(TextView)findViewById(R.id. text1 );        Typeface font = Typeface. createFromAsset (getAssets(), "font/Maximum.ttf" );        textview .setTypeface(font);

Simple Login/Register Example using SQLite database

MainActivity.java(login Screen) package com.AndroidDevelopmentGuru.database_new; import java.util.List; import android.app.Activity; import android.content.Intent; import android.database.Cursor; import android.os.Bundle; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class MainActivity extends Activity {                                 EditText user, pass;                 Button login, not_reg;                 DatabaseHandler db;                 Cursor cursor;                                 @Override                 protected void onCreate(Bundle savedInstanceState) {                                 super.onCreate(savedInstanceState);                                 setContentView(R.layout.activity_main);

Divide Layouts into Two Parts Programmatically(without using xml)

For this we just need a class and we will programmatically create the Layouts. And after this we will add Buttons in each layout. package com.AndroidDevelopmentGuru.progmatic; import android.app.Activity; import android.graphics.Color; import android.os.Bundle; import android.view.Gravity; import android.widget.Button; import android.widget.LinearLayout; import android.widget.LinearLayout.LayoutParams; public class progmmatic extends Activity {     @Override     protected void onCreate(Bundle savedInstanceState) {         // TODO Auto-generated method stub         super.onCreate(savedInstanceState);                 //creating a Linear Layout         LinearLayout parent_layout = new LinearLayout(this);        

Multiple Layouts inside a Parent Layout

To show two different layout inside a parent layout we will be working with linear layout. You just need to specify the weight of child layouts. Here goes the code: activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/rightLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" >

CheckBox in Listview Using Custom Adapter

 In this Application we just need to add a CheckBox along with the TextView. This Tutorial is an extension of ListView Using Custom Adapter  We need the following things: 1. CustomAdapter class 2. DataModel Class 3. MainActivity Class and with these classes we need only two xml files 1. activity_main.xml(xml file for MainActivity.java) 2. row.xml(To hold listview components) Here is your Code : MainActivity.java package com.AndroidDevelopmentGuru.checkbox; import java.util.ArrayList;

What is UTF? and comparision of UTF-8, UTF-16, UTF-32

Before we start discussing about UTF we need to know few basic elements. As we know that we have to encode the human understandable language into machine understandable language. To achieve this objective there are various encoding systems. Few famous encoding systems are enlisted below: ASCII: American Standard Code for information interchange(For United States) ISO 8859-1: Western European Languages KOI-8: for Russian Language

List View And GridView Layout example in Android

Listview Layout MainActivity.java package com.example.layouts; import android.os.Bundle; import android.app.Activity; import android.content.Intent; import android.view.Menu; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.Toast; import android.widget.AdapterView.OnItemClickListener; public class MainActivity extends Activity {

Custom Toast in Android

MainActivity.java package com.AndroidDevelopmentGuru.custom_toast; import android.app.Activity; import android.os.Bundle; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.widget.Toast; public class MainActivity extends Activity {     Button btn;     @Override

List inside an Alert Dialog box without using ListView

This blog is to implement the Alert Dialog comprised a list without using ListView. Code goes here. MainActivity.java package com.AndroidDevelopmentGuru.alertbox; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button public class MainActivity extends Activity {     Button b1;     @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);        

SignUp Form with Email Validation

You can use intents to transfer the data from one activity to another using. Below is an example to implement a signup form in Android MainActivity.java package com.AndroidDevelopmentGuru.registeration_form; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.text.TextUtils; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class MainActivity extends Activity {     EditText text1,text2,text3,text4,text5;     Button btn;     @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);    

ListView Using CustomAdapter with setter getter method

For this we need following three classes Main Class where we would be implementing listview using custom Adapter(CustomAdapterExample.java) Second Class for designing our Custom Adapter(CustomAdapter.java) And the last one for getter setter method for data transfer(User.java) Along with these three java classes we need two xml file one would be default xml file (activity_custom_adapter_example.xml) for main class and another one for making Listview layout (simple_list_items.xml)  In activity_custom_adapter_example.xml, take a ListView element from the Widgets and in simple_list_items.xml, take two textviews.

ListView Using SqLite Database

MainActivity.Java package com.example.nikk.nikkukaushik; import android.app.DatePickerDialog; import android.app.Dialog; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.DatePicker; import android.widget.EditText; import android.widget.ImageButton; import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; import java.util.Calendar; import java.util.List; public class MainActivity extends ActionBarActivity implements View.OnClickListener,AdapterView.OnItemSelectedListener{     MyDataHelper data1=new MyDataHelper(this);     int pos;     private ImageButton ib;     private Calendar cal;     private int day;     private int month;     private

Make your TextView Colorful in Android(Using SpannableStringBuilder)

Add Colors to your TextView There is a small trick behind this. You have to Keep the text value of textView Empty. Because the string will be written in java part this time. Here Goes the entire code for this: MainActivity.java package com.androiddevelopmentguru.spannable; import android.R.color; import android.os.Bundle; import android.app.Activity; import android.graphics.Color; import android.text.SpannableString; import android.text.SpannableStringBuilder; import android.text.style.ForegroundColorSpan;

Action Bar with Back press Enabled Button

Action bar With Back Press Enabled Button There are only three things we need to do, to achieve this objective.    Create action Bar with back button    Coding on Back button       And few changes in Manifest file 1.      Create action Bar with Button: In OnCreate() method write below given lines: getActionBar().setDisplayHomeAsUpEnabled(true);

ListView Example in Android

To create a simple listview in android as shown in below image, we generally need three things. 1. ListView 2. ArrayAdapter 3. Simple String array. Image 1 activity_main.xml

DropDown List in Android using Spinner

Usually we use drop down list in forms. In android we could achieve this using Spinner. Here goes the Code: activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:id="@+id/LinearLayout1"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical"     android:paddingBottom="@dimen/activity_vertical_margin"     android:paddingLeft="@dimen/activity_horizontal_margin"     android:paddingRight="@dimen/activity_horizontal_margin"     android:paddingTop="@dimen/activity_vertical_margin"     tools:context=".MainActivity" >

SET ENVIRONMENT VARIABLES FOR JAVA INSTALLATION

Goto MyComputer ->> Properties ->> Advanced System Settings->> Enviornment Variables After that In user variable Make a folder Named JAVA_HOME  and set its value: C:\Program Files\Java\jdk1.7.0_45\lib and click ok if that doesn't work try this: In user Variable, click on new at bottom of tab give JAVA_HOME in variable name in value : \ProgramFiles\java\jdkk1.8.0_05

Basic Concepts of Android

The android is very fast growing technology. It is an operating system for mobile devices and tabs. Sooner we will have other devices in market with android support system(For example:Washing machines, TVs, notebooks etc). If you are familiar with java then you can easily learn this technology.The basic concepts of android to start with: Core Java Concepts Android Environment Setup with Eclipse Creating an Android Emulator Activity and Intents Android Widgets