gpt4 book ai didi

android:WAITING连接时显示进度对话框

转载 作者:太空狗 更新时间:2023-10-29 15:35:24 25 4
gpt4 key购买 nike

我正在尝试在启动必须等待 Internet 响应的新 Activity 时添加进度对话框。目前屏幕在等待时变黑。有谁知道需要将它放在哪里才能工作?

这个进度对话框:

ProgressDialog dialog = ProgressDialog.show(SearchActivity.this, "", "Loading. Please wait...", true);
dialog.dismiss();

这是在 overlayActivity extends ItemizedOverlay 中:

@Override
protected boolean onTap(int index) {
final OverlayItem item = (OverlayItem) items.get(index);
final Context mContext = context;
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
builder.setTitle(item.getTitle())
.setCancelable(true)
.setPositiveButton("View Details", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Intent intent = new Intent(mContext, Profile.class);
intent.putExtra("id", item.getSnippet());
mContext.startActivity(intent);
}
});
AlertDialog alert = builder.create();
alert.show();
return true;
}

这是配置文件 Activity :

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.profile);
Bundle extras = getIntent().getExtras();
String id;

if (extras != null) {
id = extras.getString("id");

String xml = XMLfunctions.getXMLFromBarId(id); // makes httpPost call
Document doc = XMLfunctions.XMLfromString(xml);
NodeList nodes = doc.getElementsByTagName("result");
Element e = (Element)nodes.item(0);

// rest of profile created here
}
}

最佳答案

您应该使用进度对话框。 Profile Activity 中应使用进度对话框。您可以使用以下代码:

    final ProgressDialog dialog = ProgressDialog.show(MyProfileActivity.this, "","Loading..Wait.." , true);
dialog.show();
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
//your code here
dialog.dismiss();
}
}, 3000); // 3000 milliseconds

关于android:WAITING连接时显示进度对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6483451/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com