ios, swift, iphone development tutorials, x-code development

Powered by Blogger.

Main Menu

create a TableView in ios swift xcode

create a TableView in ios swift xcode It is very simple to create a table view in ios swift.But first you know that how to create a ne...

Sunday, 18 February 2018

Android Studio m hello world app bnane ka aasan trika sikhe


Android Studio m hello world app bnane ka aasan trika sikhe

To dosto aj hum dekhenge ki android studio m hello world ka pehla app kese bnate hai.
Dosto aap soch rhe honge ki ye bhut hi hard to aesa kuch nahi hai Android studio m app bnana 
bhut hi aasan hai.Aao chalo dekhte hai kese bnate h android m application.

Jesa ki humne last tutorial m humne dekha tha ki project kese create krte hai. so aj hum uske aage 
dekhenge ki app finally hum bnate kese hai.

To dosto sabse pehle to aap apna android studio ka project khol le.



Activity_main.xml(Layout)

Jesa ki aap dekh rhe h yha humne Activity_main.xml file ki image dali hai.Dosto Iska
code bhi niche m daal rha hu taki aapko smjhne m aasani rhe.


Activity_main.xml(Layout):-  

<?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="match_parent"   
    android:orientation="vertical"
    android:background="@color/colorPrimary">
    <TextView
     android:layout_width="match_parent"
     android:layout_height="wrap_content" 
     android:text="Hello world this is my first app in android"
     android:textAlignment="center"
     android:layout_marginTop="40dp"
     android:textSize="20dp"/>
</LinearLayout>

Eske ander sabse pehle btaya gya hai ki xml version konsa use ho rha hai android studio m hmare.uske baad 
<LinearLayout> jo ki layout ka kis tarah se show krana hai wo btata hai. wese hi or bhi bhut se hote hai. per hum 
basically LINEARLAYOUT or RELATIVELAYOUT ko hi use m lete hai.
uske baad Linear Layout ki height or width set krte hai ki hmare layout puri screen pe show honi chahiye ya nahi 
wo hmare pe depend krta hai hum use kesa show krwana chahte hai.
Agr hum usme color or dena chahte hai background m to background color name ki properties ko use lenge.

Ab aate hai TextView m jo ki hmare text ko application m show krane k liye use aata hai.Esme bhi hum dekhenge ki 
eski height or width kya rkhni hai.to humne esme eski Height rkhi hai "WRAP CONTENT" eska mtalab ye hai ki eski 
size utni hogi jitni mare text ki.

Fir humne "Android:text" attribute ko use liya hai jo ki hmare message ko show krane m use aayega.Or fir humne 
esko layout se topMargine diya.Ki layout ki top se kitna margine rhega.Or Last m text ko size di hai.

Ab es layout ko show krane k liye koi na koi model class ki jrurt hoti hai jo ki esko show kraye.To eske liye hum 
MainActivity,java(Class) ko use kr rhe hai.Eska code niche diya gya hai or smjhaya gaya hai.

MainActivity.java

MainActivity.java(Class)


MainActivity.java(class) Code:- 

package com.example.avi.practiceapp;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

Jesa ki aap code dekh pa rhe hai.sme sabse pehle kuch files import ki gayi hai.Ye android studio ki by default libaries hai jo
android studio khud hi project create krne k sath sath import kr leta hai.Eske baad hum aate hai 
"public class MainActivity extends AppCompatActivity".MainActivity.class

jo ki extend kr rhi hai AppcompactActivity se agr es inherit nahi krenge to humare app m 
 ERROR aayegi R(resource) ki so hume AppCompactActivity ko extend krna jruri hai.
onCreate jo ki ek method hai basically koi bhi android k project ka.Jisme hum layout ko 
set krte hai. setContentView.Layout jo ki humari UI(User Interface) hai, ki user ko 
App ka front view kesa dikhana hai.or jesa ki hum sabhi jante hai koi bhi view ko show krane 
k piche koi na koi Model class ka hath hota hai. so Usi trh hum ese bhi ek Model class ka name 
de skte kyoki Layout ko show krane k liye hum es class ki jrurat to pdegi hi pdegi.

Hamara Application bnane k baad kesa show hoga uska video niche diya gaya hai.TAki aapko ek idea
lag jaye ki application banne k baad kya output degi.




THANK YOU DOST MILTE HAI AGLE TUTORIAL M.
NOW BYE BYE TAKE CARE..!







  

0 comments:

Post a Comment