Yangi formatda davom etish uchun: https://uzfor.net/view.php?act=post&id=63491
Postga havola
NetLizard [1846] [ban]
Hammaga salom!
Mavzu ochishimdan maqsad android ilovalar tuzishga barchamizda qiziqish bor.Hamma bu qanday tuzilishiga qiziqqan albatta.Men sizlarga shu borada batafsil malumot va namunalar berib otaman.
Xudo xohlasa bu mavzuga har haftada 2 ta maqola yoziladi.Tushunmagan narsalaringiz bolsa bemalol sorang.
Demak biz boshladik.Bu ilovalar tuzish uchun nimalar zarur?
Sizga kerak boladigan narsa bu PC yoki Android smartfonning ozi.
1) PCda Android Studio, Intellij IDEA yoki Eclipseda tuzish mumkin.
2) Androidda eng yaxshisi AIDE.Bundan yaxshisiniyam yomoniniyam topolmaysiz ;)
1.1) AIDE 2.6.7 Premium yuklaymiz va ornatamiz(Premiumni spaces yoki 4pda saytidan yuklab oling)
1.2) AIDEga kiramiz, unda ekranda 4 xil bolim chiqadi, bizga keragi bu "For Experts" bolimi, shunga kiramiz.
1.3) MyApp(buni xolagancha yozish mumkin)
com.mycompany.myapp(bu ham xohishga qarab, holasangiz saytingizni domeniga qoying.Masalan, uz.uzfor.app)
********
Hozir esa saytning oddiy clientini tuzamiz.
1.4) OK bosganimizdan keyin avtomatik main.xmlga otamiz.U yerdagi barcha kodlarni ochiring(xml fayllari oson) va orniga buni yozing:
*- nima bu degan savol paydo boldimi?
Bu main.xml fayli biz unga webviewni uladik.
android:layout_width- bu ekran kengligi
android:layout_height- bu ekran boyi.
Endi AIDEda yon menyuga kiramiz va u yerdan src/com/mycompany/myapp papkadagi MainActivity.java faylga bosamiz.Barcha kodlarni tozalaymiz.Va buni yozamiz.
AndroidManifest.xmlga internet permissiyasini ulaymiz.
Yana AIDEda menyuni bosib u yerdan AndroidManifest.xml topamiz va tozalab, keyin unga quyidagicha yozamiz.
*- bu yerda ozingiz ham sezdingiz, permissiya bu yerda faqat inetga ulandi:
<uses-permission
android:name="android.permission.INTERNET" />
*- endi MainActivity.javani AndroidManifest.xmlga ulaymiz:
<activity
android:label="@string/app_name"
android:name=".MainActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
*- koryapmizki bu juda oson.bu yer .MainActivity- bu avval tuzgan MainActivity.java faylidir.
*- @string/app_name- bu res/values/strings.xml fayliga yozilgan boladi.Yozilishi oson:
<string name="app_name">Hello</string>
Tushundingiz deb oylayman.Yani <qator nomi="app_name">Hello</qatorni yopdik>
*- @drawable/ic_launcher- bu res/drawable papkadagi surat fayllari.Bu yerda ic_launcher bu ic_launcher.pngdir, yani dasturni ikonkasi.
*- action haqida gapirsak, bular ushbu dasturni ekranda korinishini taminlash uchun:
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
android:minSdkVersion="8"
- bu eng past android versiyasini korsatish, bu yerda u Android 1.6 korsatilgan.
Demak tushundingizmi @drawable- res papkadagi fayllar, @string- strings.xml faylidagi sozlar.
**********
Ertaga yana yozaman.Yangi funksiyalarni har kun qoshib organib boramiz.
Mavzu ochishimdan maqsad android ilovalar tuzishga barchamizda qiziqish bor.Hamma bu qanday tuzilishiga qiziqqan albatta.Men sizlarga shu borada batafsil malumot va namunalar berib otaman.
Xudo xohlasa bu mavzuga har haftada 2 ta maqola yoziladi.Tushunmagan narsalaringiz bolsa bemalol sorang.
Demak biz boshladik.Bu ilovalar tuzish uchun nimalar zarur?
Sizga kerak boladigan narsa bu PC yoki Android smartfonning ozi.
1) PCda Android Studio, Intellij IDEA yoki Eclipseda tuzish mumkin.
2) Androidda eng yaxshisi AIDE.Bundan yaxshisiniyam yomoniniyam topolmaysiz ;)
1.1) AIDE 2.6.7 Premium yuklaymiz va ornatamiz(Premiumni spaces yoki 4pda saytidan yuklab oling)
1.2) AIDEga kiramiz, unda ekranda 4 xil bolim chiqadi, bizga keragi bu "For Experts" bolimi, shunga kiramiz.
1.3) MyApp(buni xolagancha yozish mumkin)
com.mycompany.myapp(bu ham xohishga qarab, holasangiz saytingizni domeniga qoying.Masalan, uz.uzfor.app)
********
Hozir esa saytning oddiy clientini tuzamiz.
1.4) OK bosganimizdan keyin avtomatik main.xmlga otamiz.U yerdagi barcha kodlarni ochiring(xml fayllari oson) va orniga buni yozing:
<?xml version="1.0" encoding="utf-8"?> <WebView android:id="@ id/webView" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"/>
*- nima bu degan savol paydo boldimi?
Bu main.xml fayli biz unga webviewni uladik.
android:layout_width- bu ekran kengligi
android:layout_height- bu ekran boyi.
Endi AIDEda yon menyuga kiramiz va u yerdan src/com/mycompany/myapp papkadagi MainActivity.java faylga bosamiz.Barcha kodlarni tozalaymiz.Va buni yozamiz.
package com.mycompany.myapp; //com.mycompany.myapp bu paket nomi import android.app.*; import android.os.*; import android.webkit.*; //import orqali kerakli library va komponentlarni ulaymiz. public class MainActivity extends Activity { //MainActivityni Activity sifatida korsatdik. private WebView mWebView; //WebViewni mWebView sifatida yaratdik. public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //R.java faylga layout.mainni uladik mWebView = (WebView) findViewById(R.id.webView); // JavaScriptni webviewga uladik va uni yoqdik true orqali mWebView.getSettings().setJavaScriptEnabled(true); // yuklanish uchun sahifani korsatdik. mWebView.setWebViewClient(new MyWebViewClient()); // havola mWebView.loadUrl("http://uzfor.uz"); } private class MyWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); //sahifani yukladik. return true; } } @Override public void onBackPressed() { if(mWebView.canGoBack()) { mWebView.goBack(); //Nazad knopka bosilganda avvalgi sahifaga qaytish yoqildi, agar sahifa eng birinchisiga qaytsa yana bosganimizda dasturdan chiqadigan qildik. } else { super.onBackPressed(); } } }
AndroidManifest.xmlga internet permissiyasini ulaymiz.
Yana AIDEda menyuni bosib u yerdan AndroidManifest.xml topamiz va tozalab, keyin unga quyidagicha yozamiz.
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.mycompany.myapp" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="11" /> <uses-permission android:name="android.permission.INTERNET" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name"> <activity android:label="@string/app_name" android:name=".MainActivity" > <intent-filter > <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
*- bu yerda ozingiz ham sezdingiz, permissiya bu yerda faqat inetga ulandi:
<uses-permission
android:name="android.permission.INTERNET" />
*- endi MainActivity.javani AndroidManifest.xmlga ulaymiz:
<activity
android:label="@string/app_name"
android:name=".MainActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
*- koryapmizki bu juda oson.bu yer .MainActivity- bu avval tuzgan MainActivity.java faylidir.
*- @string/app_name- bu res/values/strings.xml fayliga yozilgan boladi.Yozilishi oson:
<string name="app_name">Hello</string>
Tushundingiz deb oylayman.Yani <qator nomi="app_name">Hello</qatorni yopdik>
*- @drawable/ic_launcher- bu res/drawable papkadagi surat fayllari.Bu yerda ic_launcher bu ic_launcher.pngdir, yani dasturni ikonkasi.
*- action haqida gapirsak, bular ushbu dasturni ekranda korinishini taminlash uchun:
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
android:minSdkVersion="8"
- bu eng past android versiyasini korsatish, bu yerda u Android 1.6 korsatilgan.
Demak tushundingizmi @drawable- res papkadagi fayllar, @string- strings.xml faylidagi sozlar.
**********
Ertaga yana yozaman.Yangi funksiyalarni har kun qoshib organib boramiz.