Chuyển đến nội dung chính

Bài đăng

Cách đọc json (bằng url GET) bằng cách kêt hợp OkHttpClient và Gson

Gỉa sử ta có đừng dẫn json như sau http://domain.com/qlvb_mobile/api/ds_donvi Có nội dung json như sau { " status ":  true , " result ": " Success " , " data ":  [    { " DV_ID ": " 10156 " , " DV_TEN ": " Sở Thông tin và Truyền thông " } ,    { " DV_ID ": " 2 " , " DV_TEN ": " Sở Tài nguyên và Môi trường " } ,    { " DV_ID ": " 3 " , " DV_TEN ": " Sở Giáo dục và Đào tạo " } ,    { " DV_ID ": " 4 " , " DV_TEN ": " Sở Văn hóa - Thể thao và Du lịch " } ], } Ta chuẩn bị 1 class như sau để nhận kết quả trả về: import com.google.gson.annotations.SerializedName ; import java.util.List ; import vn.gov.vn.quanlyvanbansonganh.model.DonVi ; public class DanhSachDonViResult { @SerializedName ( " status " ) public ...

Các cách sử dụng progressbar (có cách tạo 1 progressbar sử dụng nhiều layout)

Handling ProgressBars Edit Page Page History Overview https://guides.codepath.com/android/handling-progressbars ProgressBar is used to display the progress of an activity while the user is waiting. You can display an  indeterminate  progress (spinning wheel) or  result-based  progress. Indeterminate We can display an indeterminate progress bar which we show to indicate waiting: <ProgressBar android:id= "@+id/pbLoading" android:visibility= "invisible" android:layout_width= "wrap_content" android:layout_height= "wrap_content" /> and then manage the visibility in the activity: // on some click or some loading we need to wait for... ProgressBar pb = ( ProgressBar ) findViewById ( R . id . pbLoading ); pb . setVisibility ( ProgressBar . VISIBLE ); // run a background job and once complete pb . setVisibility ( ProgressBar . INVISIBLE ); Typically you want to try to put the  ProgressBar  in the place whe...