问题是进度微调器仅在 api 调用完成后加载。我想只有在我返回视图之后才有意义。我不确定如何在进行 api 调用之前和期间将其添加到对话框中?
protected View onCreateDialogView() {
subscriptions = null;
LayoutInflater inflater = ((SettingsActivity) ctx).getLayoutInflater();
final View vw = inflater.inflate(R.layout.channel_content_view, null);
header = ((SettingsActivity) ctx).getLayoutInflater().inflate(R.layout.channels_header,null);
((TextView) header.findViewById(R.id.channels_header)).setText("Channels");
LinearLayout linlaHeaderProgress = (LinearLayout) vw.findViewById(R.id.channelsProgress);
linlaHeaderProgress.setVisibility(View.VISIBLE);
// Do this in a new Thread
final ListView lv = (ListView) vw.findViewById(R.id.list);
// ((TextView) lv.findViewById(R.id.channel_desciption)).setText("CHANNELS");
Thread thread = new Thread()
{
@Override
public void run() {
// get the all the channels from api on web
channels = Json.getJson(apiurl + "/rest/channel/"+ linkid +"/"+ username, "GET", null);
}
};
thread.start();
lv.addHeaderView(header);
return vw;
}
频道内容视图.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/channels_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:orientation="horizontal" >
<LinearLayout
android:id="@+id/channelsProgress"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone" >
<ProgressBar
android:id="@+id/pbChannelsProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</ProgressBar>
</LinearLayout>
<ListView
android:id="@+id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants" >
</ListView>
</LinearLayout>