問題是隻有在api調用完成後纔會加載進度微調器。我想它只是在我返回視圖之後才導致出現。 我不知道如何將此添加到對話框之前和正在進行的API調用?在自定義DialogPreference中加載列表視圖之前加載進度條
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;
}
channel_content_view.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>
進度條顯示做,但它的錶盤背後ogview。我該如何使它成爲頂尖? – Harry 2013-03-15 07:24:02
我想在對話框中顯示加載欄 – Harry 2013-03-15 07:31:27
@Harry這意味着你需要一個自定義的對話框。然後,您將不得不將一個活動顯示爲一個對話框。我會更新我的答案... – 2013-03-15 08:59:14