bet 67/77 Sana 20.07.2022 Hajmi 8,33 Mb. #828560
Bog'liq
Mobil ilovalar dasturiy taminoti
“Beginning AndroidTM 4 Application Development”, by Wei-Meng Lee, printed at Radha Offset, Delhi in 2015, pages – 533. Chapter-6. Data Persisance
“Beginning AndroidTM 4 Application Development”, by Wei-Meng Lee, printed at Radha Offset, Delhi in 2015, pages – 533. Chapter-7. Content Providers
“Beginning AndroidTM 4 Application Development”, by Wei-Meng Lee, printed at Radha Offset, Delhi in 2015, pages – 533. Chapter-9. Location based services
http://www.tutorialspoint.com/android/android_google_maps.htm
https://developers.google.com/maps/documentation/android-api/start
8 – амалий машғулот
Мобил иловадарда тармоқли дастурлаш. Сервер билан ишлаш. JSON хизмати.
Ишдан мақсад: Андроид тизимида фойдаланувчи интерфейсини яратиш ва иловага мос маълумотларни сервердан ўқиб олиш, JSON хизматидан фойдаланиш кўникмаларига эга бўлиш
Масаланинг қўйилиши: Тингловчи вариант бўйича берилган лойиҳани Андроид тизимида ишлаб чиқиш ва илова учун керакли бўлган маълумотларни json хизмати орқали сервердан ўқиб олиши ва emulator орқали натижа олиши лозим.
Ишни бажариш учун наъмуна
JSON дан фойдаланиш24
Янги Андроид лойиҳа яратамиз ва уни UsingJSON деб номлаймиз
Лойиҳа қуйидаги файллардан иборат ва уларни қуйидаги слайдларда кўрсатилганидек ўзгартирамиз
res/layout/activity_main.xml
res/values/string.xml
AndroidManifest.xml
src/package/MainActivity.java
src/package/HandleJSON.java
res/layout/activity_main.xml
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=".MainActivity" >
android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_marginTop="15dp" android:text="@string/location"
android:textAppearance="?android:attr/textAppearanceMedium" />
android:id="@+id/editText1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/textView1" android:layout_alignParentRight="true" android:ems="10" />
android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/textView1" android:layout_below="@+id/textView1" android:layout_marginTop="68dp" android:text="@string/country"
android:textAppearance="?android:attr/textAppearanceSmall" />
android:id="@+id/textView3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/textView2" android:layout_marginTop="19dp" android:text="@string/temperature"
android:textAppearance="?android:attr/textAppearanceSmall" />
android:id="@+id/textView4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/textView3" android:layout_below="@+id/textView3" android:layout_marginTop="32dp" android:text="@string/humidity"
android:textAppearance="?android:attr/textAppearanceSmall" />
android:id="@+id/textView5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/textView4" android:layout_below="@+id/textView4" android:layout_marginTop="21dp" android:text="@string/pressure"
android:textAppearance="?android:attr/textAppearanceSmall" />
android:id="@+id/editText2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/textView3" android:layout_toRightOf="@+id/textView3" android:ems="10" >
android:id="@+id/editText3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBaseline="@+id/textView3" android:layout_alignBottom="@+id/textView3" android:layout_alignLeft="@+id/editText2" android:ems="10" />
android:id="@+id/editText4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/textView5" android:layout_alignLeft="@+id/editText1" android:ems="10" />
android:id="@+id/editText5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBaseline="@+id/textView5" android:layout_alignBottom="@+id/textView5" android:layout_alignRight="@+id/editText4" android:ems="10" />
android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/editText2" android:layout_below="@+id/editText1" android:onClick="open"
android:text="@string/weather" />
res/values/string.xml
"1.0" encoding="utf-8"?>
"app_name">JSONParser
"action_settings">Settings
"hello_world">Hello world!
"location">Location
"country">Country:
"temperature">Temperature:
"humidity">Humidity:
"pressure">Pressure:
"weather">Weather
src/package/MainActivity.java
public class MainActivity extends Activity {
private String url1 = "http://api.openweathermap.org/data/2.5/weather?q=";
private EditText location,country,temperature,humidity,pressure; private HandleJSON obj;
@Override
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); location = (EditText)findViewById(R.id.editText1); country = (EditText)findViewById(R.id.editText2); temperature = (EditText)findViewById(R.id.editText3); humidity = (EditText)findViewById(R.id.editText4); pressure = (EditText)findViewById(R.id.editText5);
}
Do'stlaringiz bilan baham: