Saturday, 27 August 2016

Implementation Function Handler Android (show anything after a few second)



Implementation Function Handler Android (show anything after a few second)


Hello world. Today its my second post, ya i wanna show you how to implementation function handler on the android programming. If you don't know about handler, handler is like function that you can use, if you want to show anything, with period. For example i wanna show snackbar or anything after 3 second. Lets do it.

Ahha, i've handler function like this.

private void handlerFunction(final View v){
        final Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                Snackbar.make(v, "Hi i am show after  3 second", 
                        Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        }, 3000);
    }

On this function, i just 3000 millisecond its mean 3 second waiting. And after that snackbar will show like this "Hi i am show after 3 second". Like this picture.


Implement Handler Function


If you want to show anything, you put inside run function. Just it. Write comment bellow if still confuse about my code, or comment on my Github page. I hope this is can help you little bit. Lol. Thanks.

Github page.

Share:

Create OnClick Function on The Android



Implementation onClick on the Android

Hello world. Today i wanna show you how to implementation onClick on the android programming. Basically onClick function can use for all widget in android. Something like Textview, Textfield, Button, etc. So on this post i will show you onClick just in Textview. Here we go.

This my basic layout, i call it fragment_one.xml.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="@dimen/activity_horizontal_margin_twice">

    <TextView
        android:id="@+id/tvOne"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="16dp"
        android:layout_marginTop="@dimen/activity_vertical_margin"
        android:layout_marginLeft="@dimen/activity_horizontal_margin"
        android:text="@string/fragmentOne"/>

    <View
        android:id="@+id/vOne"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="@color/colorAccent"
        android:layout_marginTop="@dimen/activity_horizontal_margin"
        android:layout_below="@+id/tvOne"/>

    <TextView
        android:id="@+id/tvOnClick"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="16dp"
        android:layout_below="@+id/vOne"
        android:layout_marginTop="@dimen/activity_vertical_margin"
        android:layout_marginLeft="@dimen/activity_horizontal_margin"
        android:text="@string/onClick"/>

    <View
        android:id="@+id/vTwo"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="@color/colorAccent"
        android:layout_marginTop="@dimen/activity_horizontal_margin"
        android:layout_below="@+id/tvOnClick"/>

</RelativeLayout>

and on this layout i've two textview that i will to implement click. And this is my function to implement my textview onClick.

private void onClick(View view){
        tvOne = (TextView) view.findViewById(R.id.tvOne);
        tvOnClick = (TextView) view.findViewById(R.id.tvOnClick);
        tvOne.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Snackbar.make(v, "Hi i am function onclick", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });
        tvOnClick.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Snackbar.make(v, "Hi i am function onclick", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });
    }

On this function i just declare my text view and call setOnClickListener . And then i put snack bar to show "Hi i am function onClick". It would be like this one.


onClick implementation Function with Snackbar



You can write comment bellow or comment on the my Github page. And also you can download it on my Github page.


Share:

Build Menu Navigation Drawer Android


Android Menu Navigation Drawer

Hello world. Its night to build something little android project and i hope in the future it will be big project for all tricks or tutorial about android project. From now i will create a tutorial on this project. Its mean, for all tutorial will do on this project. And also i will post to my Github page. So you can post comment on my Github page or on my post by post. If you still confused about structure android project you can read on my post, this one.

For first post, i share about Navigation Drawer android. It's a something like menu navigation on android apps. On the navigation drawer, i do interaction one activity and many fragment. Lets do it.

First Activity, i have xml file and one activity. So this is my xml file, i call it activity_main.xml.

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

    <include
        layout="@layout/app_bar_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <FrameLayout
        android:id="@+id/frame_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_main"
        app:menu="@menu/activity_main_drawer" />

</android.support.v4.widget.DrawerLayout>

As you can see, on this my xml file i have DrawerLayout, NavigationView, FragmentLayout, and Include. This file will be first show when app run. So we set first User Interface and Navigator User Interface. Include is another my xml file is app_bar_main. First UI it will will show like this. 


First UI Xml File



This is my app_bar_main.xml.

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="com.blogspot.dedyyuristiawan.androidstudioproject.MainActivity">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

    </android.support.design.widget.AppBarLayout>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        android:src="@android:drawable/ic_dialog_email" />

</android.support.design.widget.CoordinatorLayout>

On this file, i have CoordinatorLayout, AppBarLayout ( for put Toolbar) , and FloatingActionButton. This file it will be fist UI when you run app for first time. So for Navigation UI i put on the another xml file. Its Item menu on the folder menu, i call it activity_main_drawer.xml.

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

    <group android:checkableBehavior="single">
        <item
            android:id="@+id/fragmentOne"
            android:icon="@drawable/ic_menu_camera"
            android:title="Fragment One" />
        <item
            android:id="@+id/fragmentTwo"
            android:icon="@drawable/ic_menu_gallery"
            android:title="Fragment Two" />
        <item
            android:id="@+id/fragmentThree"
            android:icon="@drawable/ic_menu_slideshow"
            android:title="Fragment Three" />
        <item
            android:id="@+id/fragmentFour"
            android:icon="@drawable/ic_menu_manage"
            android:title="Fragment Four" />
    </group>

    <item android:title="Communicate">
        <menu>
            <item
                android:id="@+id/fragmentFive"
                android:icon="@drawable/ic_menu_share"
                android:title="Fragment Five" />
            <item
                android:id="@+id/fragmentQuit"
                android:icon="@drawable/ic_menu_send"
                android:title="Quit" />
        </menu>
    </item>

</menu>

So i have a lot item menu for navigation. and i have group for make different. It will be show like this.


Navigation UI


On this navigation, i put on the top is a header navigation and i write on this file xml. I call it nav_header_main.xml. 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="@dimen/nav_header_height"
    android:background="@drawable/side_nav_bar"
    android:gravity="bottom"
    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"
    android:theme="@style/ThemeOverlay.AppCompat.Dark">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingTop="@dimen/nav_header_vertical_spacing"
        android:src="@android:drawable/sym_def_app_icon" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="@dimen/nav_header_vertical_spacing"
        android:text="Android Studio"
        android:textAppearance="@style/TextAppearance.AppCompat.Body1" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="android.studio@android.com" />

</LinearLayout>

As you can see, i've Image and two text_view. You can imagine with Navigation UI Screen. And then as i told you before, i have activity and fragment. Navigation menu work on the one activity and a lot fragment. Its certain. This is my activity, i call it MainActivity.java. On this file will build work with xml, and make it happen like first UI. This is MainActivity.java. 

package com.blogspot.dedyyuristiawan.androidstudioproject;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.util.Log;
import android.view.View;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;

public class MainActivity extends AppCompatActivity
        implements NavigationView.OnNavigationItemSelectedListener {

    private Toolbar toolbar;
    private Fragment fragment = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        setToolbar();
        showFAB();
        setDraawerLayout();
        setNavigation();
        setFirstFragment();
    }

    //function for set first fragment run
    private void setFirstFragment(){
        Fragment fragment = null;
        fragment = new FragmentOne();
        FragmentManager fragmentManager = getSupportFragmentManager();
        fragmentManager.beginTransaction()
                .replace(R.id.frame_container, fragment).commit();
    }

    //private void set navigation
    private void setNavigation(){
        NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
        navigationView.setNavigationItemSelectedListener(this);
    }

    // function to set drawer layout
    private void setDraawerLayout(){
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.setDrawerListener(toggle);
        toggle.syncState();
    }

    // function to set toolbar
    private void setToolbar(){
        toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
    }

    //function to call fab
    private void showFAB(){
        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });
    }

    // function to detect back button, when user click button back
    // it will close drawer
    // and close app
    @Override
    public void onBackPressed() {
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        if (drawer.isDrawerOpen(GravityCompat.START)) {
            drawer.closeDrawer(GravityCompat.START);
        } else {
            super.onBackPressed();
        }
    }

    //function for create menu, on the left top tollbar
    // it declare from xml menu, folder menu
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    // function to create action click when user click menu on the menu folder
    // you can check on the menu folder
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

    // function to create action click when user click navigation menu item
    // id it from menu folder
    // and also will change one fragment to another fragment, with replace
    // after change fargment will close drawer too
    @SuppressWarnings("StatementWithEmptyBody")
    @Override
    public boolean onNavigationItemSelected(MenuItem item) {
        // Handle navigation view item clicks here.

        int id = item.getItemId();
        //declare fragment
        Fragment fragment = null;

        //select fragment with id condition
        //set tittle bar
        //call fragment
        if (id == R.id.fragmentOne) {
            Log.d("fragmentOne Test","Works" );
            getSupportActionBar().setTitle(R.string.fragmentOne);
            fragment = new FragmentOne();

        } else if (id == R.id.fragmentTwo) {
            Log.d("fragmentTwo Test","Works" );
            getSupportActionBar().setTitle(R.string.fragmentOne);
            fragment = new FragmentOne();

        } else if (id == R.id.fragmentThree) {
            Log.d("fragmentThree Test","Works" );
            getSupportActionBar().setTitle(R.string.fragmentOne);
            fragment = new FragmentOne();

        } else if (id == R.id.fragmentThree) {
            Log.d("fragmentThree Test","Works" );
            getSupportActionBar().setTitle(R.string.fragmentOne);
            fragment = new FragmentOne();

        } else if (id == R.id.fragmentFour) {
            Log.d("fragmentFour Test","Works" );
            getSupportActionBar().setTitle(R.string.fragmentOne);
            fragment = new FragmentOne();

        } else if (id == R.id.fragmentFive) {
            Log.d("fragmentFive Test","Works" );
            getSupportActionBar().setTitle(R.string.fragmentOne);
            fragment = new FragmentOne();

        } else if (id == R.id.fragmentQuit){
            Log.d("fragmentQuit Test","Works" );
            getSupportActionBar().setTitle(R.string.fragmentOne);
            finish();
        }

        //interaction fragment, with replace
        //close navigator
        if (fragment != null) {
            FragmentManager fragmentManager = getSupportFragmentManager();
            fragmentManager.beginTransaction()
                    .replace(R.id.frame_container, fragment).commit();

            DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
            drawer.closeDrawer(GravityCompat.START);

        } else {
            // error in creating fragment
            Log.e("MainActivity", "Error in creating fragment");
            DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
            drawer.closeDrawer(GravityCompat.START);
        }

        return true;
    }
}

On this file, i've to write comment on the function to so you can learn and understand it. The important is on the top function is a onCreate(Bundle savedInstanceState) . Its first function when app run. After that will call another function like this. 

setToolbar();
        showFAB();
        setDraawerLayout();
        setNavigation();
        setFirstFragment();

simple right? there is another java file, it's a fragment file. As you can see, activity will be make interaction with fragment see on the onNavigationItemSelected function. I can replace it with another function. But i create one fragment. haha its ok, you can create yourself. So this is my fragment class.

package com.blogspot.dedyyuristiawan.androidstudioproject;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by dedyyuristiawan on 8/27/16.
 */
public class FragmentOne extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View rootView = inflater.inflate(R.layout.fragment_one, container, false);

        return rootView;
    }
}

As you can see, on my fragment have xml too. And this is my xml file. I call it fragment_one.xml.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <TextView
        android:id="@+id/tvOne"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="16dp"
        android:text="Hello World!"
        android:layout_centerInParent="true"/>

    <TextView
        android:id="@+id/txtLabel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/tvOne"
        android:layout_centerInParent="true"
        android:textSize="16dp"
        android:text="@string/fragmentOne"/>

</RelativeLayout>

That's it. Android Navigator Apps. If you still have confuse about my code you can fill comment bellow, or just sent email to me (bellow my photo). Remember it will change when i write post. Cause all tutorial i will create on this project. If you want to see about previous code, you can search on the commit Github Page. And this is my project, Just download it on my Github page. 

Github page.

Share:

Thursday, 25 August 2016

Show Count Down Timer Android



Android Count Down Timer


Hello world. As i promise about my post that i wanna share about android programming, so today i am gonna show you how to show count down timer on android. Ahaa good, its something like timer in your clock app, but in this post i will show you count down. Its mean timer will be show from top to bottom. Lets do this.

On this case i just one have activity and one layout. This is simple you can learn on this page android developer. this is 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" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_gravity="center_vertical"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/tvTimeCount"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="00:00"
            android:textSize="40dp"
            android:layout_marginTop="30dp"/>

    </LinearLayout>

</LinearLayout>

i got conclusion like this :

1.  android:text="00:00" on my text_view, I can set text string " 00 : 00".
2.  android:textSize="40dp" and then i can set size 40dp.
3.  android:layout_marginTop="30dp" i can set margin top 30dp.
4. and the last this is really important is android:id="@+id/tvTimeCount" . i've id that will call on my java code.

And this one is my main_activity.java .

public class MainActivity extends AppCompatActivity {

    private TextView textViewShowTime;
    private CountDownTimer countDownTimer;
    private long totalTimeCountInMilliseconds;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        textViewShowTime = (TextView) findViewById(R.id.tvTimeCount);
        startTimer(2);
    }

    private void startTimer(int time) {
        totalTimeCountInMilliseconds = 60 * time * 1000;
        totalTimeCountInMilliseconds = totalTimeCountInMilliseconds + 1000;
        countDownTimer = new CountDownTimer(totalTimeCountInMilliseconds, 1000) {

            @Override
            public void onTick(long leftTimeInMilliseconds) {
                long seconds = leftTimeInMilliseconds / 1000;
                String minute =  String.format("%02d", seconds / 60);
                String second =  String.format("%02d", seconds % 60);
                textViewShowTime.setText(minute+" : "+ second);
            }

            @Override
            public void onFinish() {
                textViewShowTime.setText("Time up!");
            }
        }.start();
    }
}

i got conclusion that :

1. Declaration your text_view with (TextView) findViewById(R.id.tvTimeCount);
2. Call my function, i set 2. its mean 2 minutes. startTimer(2);
3. totalTimeCountInMilliseconds = 60 * time * 1000; Calculate int to minutes. in android 1 second is 1000 millisecond. Remember!!
4. Call basic function CountDownTimer with parameter our minutes and speed (1000 millisecond normal ).
5. Create logic to get minutes and seconds. with divide and modulus ( / and % ).
6. Show your minutes and seconds with little modification.
    textViewShowTime.setText(minute+" : "+ second);
7. Funtion onTick() is time still on workingm but deferent with onFinish() is time is stop. So on this case when time still working my text view, i put time and then when stop i put string "time is up".

Yup this is my little trick about timer on android, i hope this is can help you little bit. And also you can download on my github link. Thanks.

Github link
Share:

Sunday, 26 June 2016

Make Splash Screen with Animation Android Application


https://dedyyuristiawan.blogspot.com


Hello world. Today i wanna show how to create slash screen with animation in android apps. In this post i am use small to big to small animation, you can see in demo apps. I am using last android studio and lollipop minimum sdk. lest do this.

First important thing if you want to make splash screen is logo, this is important for you and make your logo to png file, cause it can be our android apps runs fast. Splash screen its a activity so we make first activity for splash screen. This is important code in screen activity.

new Handler().postDelayed(new Runnable() {
 @Override
    public void run() {
        Intent i = new Intent(SplashScreen.this, MainActivity.class);
        startActivity(i);
        finish();
    }
}, SPLASH_TIME_OUT);

So the purpose for this function is before we move to another activity (main activity class), the screen activity will hold until splash_time_out done. splash_time_out is integer variable. In this case i set 3000 it mean 3 second. Yup its purpose we make hander in splash screen activity.

Whats about xml layout? in xml layout i just put image and text, and image and text i will make animation. Actually this layout is similar with another layout, you can see in the my demo code.

The second thing i wanna make animation in the splash screen. So this is my important code in splash screen activity.

protected void onResume() {
    super.onResume();
    logo_holder.startAnimation(anim_logo);
    Handler handler = new Handler();
 Runnable startMain = new Runnable() {
  @Override
  public void run() {
   if (!isFinishing()){
    text_holder.startAnimation(anim_txt);
   }
  }
 };
 handler.postDelayed(startMain, 200);    
}

 The purpose onResume function is make logo_holder to start animation (anim_logo is code xml i put in the anim folder on res) and then after image done for the animation, text will be show after image done, see in condition (if finishing). 

You can download my source code bellow, after this you can see my code and understand it, if you still confuse about code, you can write comment bellow. Thanks.

Source Code Github
Share:

Thursday, 23 June 2016

Create First Android Application with Android Studio


https://dedyyuristiawan.blogspot.com


Hello world. Today i will show you how create first android apps / application with android studio. Now i am use mac operating system for develop apps. Basically create android apps its so easy if you have basic programming language, for specifically Java Programming. I suppose you if you want to develop android apps, please use android studio, latest update SDK. If you have everything like that it can help you to develop android apps something like reduse minimum issue, beautiful design, and know news update about android. Yoyoy we can start now step by step.


1. Install Latest Java JDK Version

You can download here in oracle. I suppose you to download and install latest version because we can reduce minimum issue for android studio and support for android studio work fine.

2. Install Android Studio Version

You can download android studio here in developer android studio. Again i suppose you to download and install because we can reduce issue (android studio its still young), make beautiful design and develop android app with last operating system. You can follow step by step to install whenever in mac, windows and linux in there. 

3. Install Last SDK

In the third step you can install all sdk in android studio. Pick Configure > SDK Manager > Launch Standalone SDK Manager, and install everything in there if you want easy to develop android apps, no more issue. After that your ready to develop android apps.

3.  Hello World Project

Open you android studio and pick start a new Android Studio Project.


https://dedyyuristiawan.blogspot.co.id
First Screen Android Studio Menu


First Screen write your application name. Pick Location that you want save your android project. Click next

https://dedyyuristiawan.blogspot.co.id
Write Android App Name


Second screen just pick minimum sdk (its minimum os android for your android apps). After that you can choose version that you want to develop whenever in Phone and Tablet, Wear, Tv, Android Auto, Glass. Click next.

https://dedyyuristiawan.blogspot.co.id
Choose Target Android App


Third screen you can pick layout whenever its basic activity, empty activity etc. In this post i will choose empty activity. And then click next.


https://dedyyuristiawan.blogspot.co.id
Choose App Template Screen



Fourth screen just let all default, click finish, and wait. Its just name for java file and xml file. i will guide to learn structure about android project.


https://dedyyuristiawan.blogspot.co.id
Write Name Java Xml File


Now you can run your android project. But before we run project i will set user interface android so we can understand so easily about structure android project.  Pick android and choose project.


https://dedyyuristiawan.blogspot.co.id
Change Project UI Screen


and stucture android project will be like that.


https://dedyyuristiawan.blogspot.co.id
Project UI Easy to Undersatand


In java folder its for we write java code and logically android project runs. File MainActivity.java its for runs xml file look this code.

setContentView(R.layout.activity_main);

Move to xml file, you can move to res folder > layout > activity_main.xml. Look from the top from default xml had relative layout and text view. Textview its for show with text  'Hello World' in screen android, you can look in preview screen

android:text="Hello World!"

https://dedyyuristiawan.blogspot.com
Xml Hello World


There is another folder that you can use its drawable folder. In this folder you can put image, xml file and etc i will tell you more in next post.

Mipmap folder its for image for with different dimension to fix screen in android phone. For example default its ic_launcher.png its a logo android app. You can look when android project run.


https://dedyyuristiawan.blogspot.co.id
Mipmap Folder


Values folder its for you to set color, string (text), dimes (dimension), and style (usually its for theme android apps)

https://dedyyuristiawan.blogspot.co.id
Values Folder 


The important file its AndroidManifest.xml its for manage your activity, theme, and name of android apps. see and understand it. There another file that important in android project is a build.gradle file. This file if want to use library in folder or web, so android studio can automatically add library if you put link in dependency code.

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
}

https://dedyyuristiawan.blogspot.co.id
Build.Gradle File


if you want to use library android just put bellow  compile 'com.android.support:appcompat-v7:23.4.0' and click sync, android will automatically add library in you android project.

So if you understand with all of that we can run android project or you can write comment in bellow. Before you want run android project android studio you must create android virtual device with this step :

Click button run app (green triangle in top) > 
Create emulator > choose phone that you want > next > 
Choose os android (i suppose you to choose os with ABI x86, because it can help emulator run fast) > next > 
Write your avd name > finish > wait > 
Choose adv that you created > click ok and emulator android will be show.

Yoyoy its post about create first android apps, if you still have confuse about my post you can write comment bellow and i hope can help you to first develop android apps. And the last you can download this app in my github Thanks.

Github Source Code and my All Picture Post.



Share:


<br>


Advice for contacting me at dedyy54@gmail.com