机器人:等待连接时显示进度对话框 [英] android: displaying progress dialog when waiting for connection
本文介绍了机器人:等待连接时显示进度对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想添加进度对话框,当一个新的活动推出,有等待来自网络的响应。此刻屏幕才行,而它正在等待黑色。是否有任何人知道它需要放在工作?
这progressDialog:
ProgressDialog对话框= ProgressDialog.show(SearchActivity.this,,请耐心等待...,真正的);
dialog.dismiss();
这是在overlayActivity延伸ItemizedOverlay:
@覆盖
受保护的布尔中的onTap(INT指数){
最后OverlayItem项目=(OverlayItem)items.get(指数);
最后上下文mContext =环境;
AlertDialog.Builder建设者=新AlertDialog.Builder(mContext);
builder.setTitle(item.getTitle())
.setCancelable(真)
.setPositiveButton(查看详情,新DialogInterface.OnClickListener(){
公共无效的onClick(DialogInterface对话框,INT ID){
意向意图=新的意图(mContext,Profile.class);
intent.putExtra(ID,item.getSnippet());
mContext.startActivity(意向);
}
});
AlertDialog警报= builder.create();
alert.show();
返回true;
}
这就是档案的活动:
公共无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.profile);
捆绑额外= getIntent()getExtras()。
字符串ID;
如果(临时演员!= NULL){
ID = extras.getString(ID);
XML字符串= XMLfunctions.getXMLFromBarId(ID); //使httpPost电话
文档DOC = XMLfunctions.XMLfromString(XML);
节点列表节点= doc.getElementsByTagName(结果);
元素e =(元)nodes.item(0);
//配置文件的其余部分在这里创建
}
}
解决方案
您应该使用进度对话框。应在配置文件活动中使用进度对话框。 您可以使用下面的code:
最后ProgressDialog对话框= ProgressDialog.show(MyProfileActivity.this,,Loading..Wait ..,真正的);
dialog.show();
处理程序处理程序=新的处理程序();
handler.postDelayed(新的Runnable(){
公共无效的run(){
//你的code在这里
dialog.dismiss();
}
},3000); // 3000毫秒
I am trying to add a progress dialog when a new activity is launched that has to wait for a response from the internet. At the moment the screen just goes black while it is waiting. Does any one know where it needs to be placed to work?
this progressDialog:
ProgressDialog dialog = ProgressDialog.show(SearchActivity.this, "", "Loading. Please wait...", true);
dialog.dismiss();
this is in the 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;
}
and this is the Profile 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
}
}
解决方案
You should use Progress dialog. Progress dialog should be used in the Profile activity. You can use the following code:
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
这篇关于机器人:等待连接时显示进度对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文