Yangi formatda davom etish uchun: https://uzfor.net/view.php?act=post&id=63547
Postga havola
NetLizard [1846] [ban]
Hammaga salom!
Demak endi dasturlarimizda "SplashScreen" qoshishni organamiz.
*- Eslatib otaman, dasturlarimiz Google java va xml DTga asoslangan.
Tak birinchidan biz yangi proyekt tuzamiz.
Va keyin res/layout/ papkaga kiramiz, u yerda main.xml fayl bor, unga tegmaymiz.Yoniga qoshimcha splash.xml fayl yaratamiz, ichiga buni yozamiz:
*- yuqorida <ImageView ichida android:src="@drawable/logo kabi satr bor, demak res/drawable papka ichiga logo.png surat joylashimiz kerak.
----------------
Endi esa src/com/company/splash/ papkaga kirib u yerda SplashActivity.java fayl tuzamiz, keyin ichiga buni yozamiz:
Endi AndroidManifest.xmlga splashActivityni qoshib qoyamiz.
*- MainActivitydan oldin qoshamiz.
AIDE Menyusidan "RUN" bolimini bosamiz va kutamiz.
Ekranda: "Compiling, Dexing-Classes,Dexing-Merging,Building APK,Signing APK" yozuvlari chiqadi.
Compiling- bu kompilyatsiya qilmoqda
Dexing-Classes- MainActivity.java va SplashActivity.javani .dex(dalvik executable)ga otkazmoqda
Dexing-Merging-Merge qilmoqda
Building APK- apk tuzilmoqda
Signing APK- apk sertifikatlanmoqda(odatda testkey boladi)
Pastda esa namuna va isxodniy kodlar.
Demak endi dasturlarimizda "SplashScreen" qoshishni organamiz.
*- Eslatib otaman, dasturlarimiz Google java va xml DTga asoslangan.
Tak birinchidan biz yangi proyekt tuzamiz.
Va keyin res/layout/ papkaga kiramiz, u yerda main.xml fayl bor, unga tegmaymiz.Yoniga qoshimcha splash.xml fayl yaratamiz, ichiga buni yozamiz:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:background="#000000"> <ImageView android:id="@+id/logo" android:layout_width="match_parent" android:layout_height="250dp" android:layout_centerInParent="true" android:src="@drawable/logo" android:visibility="visible"/> <View android:layout_height="57dp" android:background="?android:attr/dividerVertical" android:layout_width="match_parent" android:visibility="invisible"/> <TextView android:layout_height="wrap_content" android:text="SplashScreen Demo" android:textAppearance="?android:attr/textAppearanceLarge" android:layout_width="wrap_content" android:layout_gravity="center" android:textColor="#FFFFFF" android:visibility="visible"/> <TextView android:layout_height="wrap_content" android:text="http://masteros.tk" android:textAppearance="?android:attr/textAppearanceSmall" android:layout_width="wrap_content" android:layout_gravity="center" android:textColor="#6090EF" android:visibility="visible"/> </LinearLayout>
*- yuqorida <ImageView ichida android:src="@drawable/logo kabi satr bor, demak res/drawable papka ichiga logo.png surat joylashimiz kerak.
----------------
Endi esa src/com/company/splash/ papkaga kirib u yerda SplashActivity.java fayl tuzamiz, keyin ichiga buni yozamiz:
package com.mos; //lib va modullarni import qilamiz. import android.os.Bundle; import android.os.Handler; import android.app.Activity; import android.content.Intent; import android.view.Menu; public class SplashActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.splash); // Thread yaratamiz Thread background = new Thread() { public void run() { try{ // 4 sekundlik thread sleep(4*1000); // 4 sekundlik splashdan song MainActivity.java intentga otkazamiz Intent i= new Intent(getBaseContext(),MainActivity.class); startActivity(i); //Splashni yoqotish finish(); } catch(Exception e) {}}}; // thread ochildi background.start(); } @Override protected void onDestroy() { super.onDestroy(); }}
Endi AndroidManifest.xmlga splashActivityni qoshib qoyamiz.
*- MainActivitydan oldin qoshamiz.
<application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:label="@string/app_name" android:name=".SplashActivity" > <intent-filter > <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
AIDE Menyusidan "RUN" bolimini bosamiz va kutamiz.
Ekranda: "Compiling, Dexing-Classes,Dexing-Merging,Building APK,Signing APK" yozuvlari chiqadi.
Compiling- bu kompilyatsiya qilmoqda
Dexing-Classes- MainActivity.java va SplashActivity.javani .dex(dalvik executable)ga otkazmoqda
Dexing-Merging-Merge qilmoqda
Building APK- apk tuzilmoqda
Signing APK- apk sertifikatlanmoqda(odatda testkey boladi)
Pastda esa namuna va isxodniy kodlar.