[英]Spinner OnItemSelected firing unexpectedly causing UI problems
I have an app that access the internet. 我有一个可以访问互联网的应用程序。 It parses a page (like StackOverflow) with headlines and pages.
它解析带有标题和页面的页面(如StackOverflow)。
I have an AsyncTask that gets the headlines for those pages, and I have a hovering spinner on the bottom with the pages. 我有一个AsyncTask来获取这些页面的标题,并且在页面的底部有一个悬停的微调器。 The spinner has an OnItemSelectedListener that fires the AsyncTask with the page attached to it:
微调器有一个OnItemSelectedListener,它会触发AsyncTask及其附加的页面:
spinner1.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent,
View view, int position, long arg3) {
Log.i("ONITEMSELECTED", "ClickedCount: " + clickedCount
+ ", initCount: " + initCount);
if (initCount != clickedCount) {
clickedCount++;
Log.i("SELECTED", "Called");
} else {
initCount++;
String page = adapter2.getItem(position);
new ParseHTML()
.execute(
"http://m.eksisozluk.com/index/today",
page);
Log.i("SELECTED", "Page loading: " + page);
}
}
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
As you can see, I tried counting the clicks and loads of the onItemSelected
, but this causes to load the pages correctly, but it puts the Spinner
to page 1, even if I have selected page 8. How can I ensure this type of loading will work on my app? 如您所见,我尝试计算
onItemSelected
的点击和负载,但这会导致正确加载页面,但是即使选择了第8页,它也会将Spinner
置于第1页。如何确保这种类型的加载可以在我的应用程序上运行吗?
Spinner1.setSelection(position);
在onItemSelected中使用它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.