1,516 ko'rilgan
Bu mavzu o'zbek tilida bo'limida 16 Iyun, 16 da maqola yozgan.
20 Iyun, 16 Qayta tahrirladi!

Android Studio muhutida birinchi android ilova dasturini "tugma" yaratish va "Salom!! Qanday-Qilib.uz sayiti a`zolari" deb nomlangan habarni chiqarish

1)Dastlab Android Studio Muhidi(Dasturi) ishga tushuriladi va "Star anew Android Studio project" tugmasi bosiladi:

2)Ilova dastur nomi kiritiladi(Nom sifatida Ingiliz alifbosi hariflaridan Aa..Zz gacha foydalaning) va "Next" tugmasini bosing:

3) Android OS platformasi versiyasi belgilanadi va "Next" tugmasi bosiladi:

4) "Empty Activity" formasi belgilanadi va "Next" tugmasi bosiladi:

5) Java hamda XML fayillari nomi kiritiladi va "Finish" tugmasi bosiladi:

6) first_app.xml fayili ochiladi va bitta "Button" companentasi virtual smartfonning o`rtasiga qo`yiladi:

7) Qo`yilgan tugma ustida sichqonchaning chap tugmasini ikki martta bosib companentaning "text" xsusiyatidagi so`z o`zgartiriladi:

8) "FirstApp.java" fayilini ochib quyda belgilangan java kodlari kiritiladi:
    //button toifasida global o`zgaruvchi:
    Button button;
    
    A) xml fayilidagi button tugmasini java kodlariga ulash
    button = (Button)findViewById(R.id.button);
    
    B) button companentasining bosilish xsusiyatini yaratish
    button.setOnClickListener(new View.OnClickListener(){
        @Override
        public void onClick(View v){
            XabarChiqarish();
        }
    });
    
    C) Xabar chiqarish funksiyasini yaratish
    public void XabarChiqarish(){
        Toast.makeText(FirstApp.this,"Salom!!! Qanday-Qilib.uz sayiti a`zolari", Toast.LENGTH_SHORT).show();
    }
    


Yaratilgan dasturni "apk" farmatiga o`tkazib shahsiy smartfonlarda ishga tushurish:

1) Yuqori menyu bo`limidan "Bueld-->Generate Signet APK" bosiladi va quydagi ketma-ketliklar bajariladi



2) "Create new" tugmasi bosiladi:



3) Project fayillari joylashgan papka yuli ko`rsatiladi "shift+enter":




4) Quyda hosil bulgan oynaning Password bo`limiga ixtiyoriy 6 belgidan kam bulmagan parol kiritiladi:
    key: bo`limida "Alias" qatoriga ixtiyoriy ingiliz hariflaridan kiritiladi:
    va uning "Password" qatoriga 6 belgidan kam bo`lmagan ixtiyoriy paroll kiritiladi va "Okey" tugmasi bosiladi


5) Hosil bo`lgan oynadan "Next" tugmasi undan keyingi oynadan "Finish" tugmasi bosiladi:



6) Dastur apk farmatiga o`tkazib bulingandan keyin fayil joylashgan papkani ochib berish yoki xabarni yopish xaqida xabar oynasi hosil bo`ladi:
    va "Show in Explorer" xizmati bosiladi. Natijada hosil bo`lgan apk fayili joylashgan papka ochib beriladi:


...


ushbu fayilni shahsiy smartfoningizda yoki PC uchun maxsus yaratilgan BlueStacks dasturi yordamida ishga tushurish mumkun.
Omad!!!
 

____________________________________________________________________________________

To`liq kodlar:

____________________________________________________________________________________
FirstApp.java fayili:

package com.example.android.myfirstandroidapp;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class FirstApp extends ActionBarActivity {
    Button button;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.first_app);

        button = (Button)findViewById(R.id.button);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                XabarChiqarish();
            }
        });
    }

    public void XabarChiqarish(){
        Toast.makeText(FirstApp.this, "Salom 'Qanday-Qilib.uz sayiti A`zolari!!'", Toast.LENGTH_SHORT).show();
    }
}

_______________________________________________________________________________________

first_app.xml fayili:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    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="com.example.android.myfirstandroidapp.FirstApp">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Xabar chiqarish"
        android:id="@+id/button"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true" />
</RelativeLayout>

______________________________________________________________________________________________

Natijalar:

04 Avg, 16 Izoh qoldirgan
Raxmat @Ahad topalmayotgandim!
06 Avg, 16 Izoh qoldirgan
Menda .jks fayli chiqmayapdi. Qatta bo'ladi u? Android studio 2.1.2 versia
07 Avg, 16 Izoh qoldirgan
JDK faylni aloxida olishiz kere! mnogo.uz da bo'lishi mumkin!
21 Avg, 16 Izoh qoldirgan
Salom shu android studio dasturi haqida ham ozroq malumot berolasizmi? android studio 32 bit ga xam tushaveradimi?
26 Avg, 16 Izoh qoldirgan
salom hammaga km bladi qanaqb shu errorni tuzatsa bo'ladi new project qlganda chiqyapti

O'xshash maqolalar bilan tanishing

475 ko'rilgan
HelloWorld! Bu mavzu o'zbek tilida bo'limida 17 Iyun, 16 da maqola yozgan.
27 ko'rilgan
25 ko'rilgan
...