或者如何制作动画,加载RecyclerView? 我使用示例中的RecyclerView,该片段中的基本实现。
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{ mApplicationAlbum = new ApplicationAlbum();
var view = inflater.Inflate(Resource.Layout.fragment1, container, false);
mRecyclerView = view.FindViewById<RecyclerView>(Resource.Id.recyclerView);
mLayoutManager = new LinearLayoutManager(Activity);
mRecyclerView.SetLayoutManager(mLayoutManager);
mAdapter = new ApplicationAlbumAdapter(mApplicationAlbum);
mAdapter.ItemClick += OnItemClick;
mRecyclerView.SetAdapter(mAdapter);
var ignored = base.OnCreateView(inflater, container, savedInstanceState);
return view; }
适配器从json接收数据
WebClient client = new WebClient();
var json = client.DownloadString("http://....../application.php");
Application[] mBuiltInApplication = JsonConvert.DeserializeObject<Application[]>(json);
mApplications = mBuiltInApplication;
调用片段
SupportFragmentManager.BeginTransaction()
.Replace(Resource.Id.content_frame, Fragment1.NewInstance())
.Commit();
此解决方案效果很好。
我想解决该问题,如果从Json下载的时间较长,则应用程序挂起,用户界面无响应。
如何在屏幕上显示加载动画,而在后台线程中将加载json,并在成功下载后显示。
希望您能理解我想做什么。