我有一些这样的代码:
ArrayList<Teacher> teachers = subs.get(position).getTeachers();
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
View v = LayoutInflater.from(MainActivity.this).inflate(R.layout.dialog_layout, null);
builder.setView(v);
ListView listViewDialog = (ListView) v.findViewById(R.id.dialog_lv);
TesAdapter adapter1 = new TesAdapter(MainActivity.this, teachers);
listViewDialog.setAdapter(adapter1);
adapter1.notifyDataSetChanged();
listViewDialog.setDivider(null);
builder.show();
此操作需要很长时间。所以,我正在尝试在加载时显示ProgressDialog。然后隐藏进度条并显示此AlertDialog。
我试过这些:
How to show progress dialog in Android?
How can I run code on a background thread on Android?
但他们都没有工作:(任何解决方案?