【发布时间】:2011-06-01 07:12:45
【问题描述】:
我正在开发一个 android 应用程序,在通过单击“确定”按钮从编辑文本框中获取字符串后,我将字符串从一个活动传递到另一个活动。字符串是一个提供 rss 提要的 url。所以加载它需要一点时间。我想显示一个进度条以保持界面交互。如何在同一个按钮单击上实现进度条或进度对话框?
我的活动代码片段是
EditText Urlis=(EditText)findViewById(R.id.entry);
final Button button = (Button) findViewById(R.id.ok);
final Intent i=new Intent(this , RSSReder.class);
final String choice=Urlis.getText().toString();
i.putExtra("key", choice);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
startActivity(i);
}
});
}
}
下一个活动的部分代码是
公共类 RSSReder 扩展 Activity 实现 OnItemClickListener {
public String RSSFEEDOFCHOICE;
public final String tag = "RSSReader";
private RSSFed feed = null;
/** Called when the activity is first created. */
public void onCreate(Bundle abc) {
super.onCreate(abc);
setContentView(R.layout.next1);
Intent i = getIntent();
RSSFEEDOFCHOICE =i.getStringExtra("key");
// go get our feed!
feed = getFeed(RSSFEEDOFCHOICE);
// display UI
UpdateDisplay();
}
【问题讨论】:
-
您是否使用新类(RSSReader.class)中上一个活动的 url 显示 webview...?
-
Dinesh 我在列表视图的新活动中获得 RSS 提要
-
你能发布一些新活动的代码,你实际上在那里做什么......?
-
我刚发了请看
-
如果 getFeed() 是阻塞调用,您的应用程序肯定会 ANR。您应该考虑在 IntentService 中进行提要下载。
标签: android button progress-bar