但在我的应用程序中,ScrollTo函数似乎没有反应.
这是我的代码.
protected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.reader); scrollVIEw = (ScrollVIEw)findVIEwByID(R.ID.Scroll); text = (TextVIEw)findVIEwByID(R.ID.text); Tagsbutton = (Imagebutton)findVIEwByID(R.ID.Tags); openbutton = (Imagebutton)findVIEwByID(R.ID.Open); text.setTextcolor(color.RED); text.scrollTo(0,index); }//Here the scrollTo do not work...
onCreate中的过程并不重要,所以我删除了它们.
令我困惑的是,在下面的方法中,方法滚动可以工作…
protected voID onActivityResult(int requestCode,int resultCode,Intent data) { super.onActivityResult(requestCode,resultCode,data); if(data!=null){ Bundle bundle = data.getExtras(); if(bundle!=null){ int index = bundle.getInt("Index"); String file_name = bundle.getString("file_name"); Readfile(file_name); scrollVIEw.scrollTo(0,index); text.postInvalIDate(); } }
我不认为这两种方法之间存在太大差异……但为什么……
有人可以帮帮我吗?
多谢.
解决方法 在你的onCreate尝试text.post(new Runnable() { @OverrIDe public voID run() { text.scrollTo(...); } });总结
以上是内存溢出为你收集整理的android – 方法ScrollTo没用全部内容,希望文章能够帮你解决android – 方法ScrollTo没用所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)