Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Context Menu được chọn trong vòng cuối. Một thực hiện bộ xương được hiển thị dưới đây:Bắt đầu bằng cách nhập khẩu các gói bạn cần phải hỗ trợ chức năng trình đơn vào các lớp học cuối ToDoList.nhập khẩu nhập khẩu nhập khẩu | Chapter 5 Intents Broadcast Receivers Adapters and the Internet ArrayAdapter Quake aa ArrayList Quake earthquakes new ArrayList Quake Override public void onCreate Bundle icicle super.onCreate icicle setContentView R.layout.main earthquakeListView ListView this.findViewByld R.id.earthquakeListView int layoutID android.R.layout.simple_list_item_1 aa new ArrayAdapter Quake this layoutID earthquakes earthquakeListView.setAdapter aa 4. Next you should start processing the earthquake feed. For this example the feed used is the 1-day USGS feed for earthquakes with a magnitude greater than 2.5. Add the location of your feed as an external string resource. This lets you potentially specify a different feed based on a user s location. xml version 1.0 encoding utf-8 resources string name app_name Earthquake string string name quake_feed http earthquake.usgs.goV eqcenter catalogs 1day-M2.5.xml string resources 5. Before your application can access the Internet it needs to be granted permission for Internet access. Add the uses-permission to the manifest. uses-permission xmlns android http schemas.android.com apk res android android name android.permission.INTERNET uses-permission 6. Returning to the Earthquake Activity create a new refreshEarthquakes method that connects to and parses the earthquake feed. Extract each earthquake and parse the details to obtain the date magnitude link and location. As you finish parsing each earthquake pass it in to a new addNewQuake method. The XML parsing is presented here without further comment. private void refreshEarthquakes Get the XML URL url try String quakeFeed getString R.string.quake_feed url new URL quakeFeed URLConnection connection 150 Chapter 5 Intents Broadcast Receivers Adapters and the Internet connection url.openConnection HttpURLConnection httpConnection HttpURLConnection connection int responseCode httpConnection.getResponseCode if responseCode HttpURLConnection.HTTP_OK InputStream in httpConnection.getInputStream .