将ScrollView聚焦在android中的页面顶部 [英] Focus ScrollView On Top Of Page in android

查看:66
本文介绍了将ScrollView聚焦在android中的页面顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在执行一个Activity,其中有一些View是textViews ImageViews和MapView,最后是页面上的listview.

I am having an Activity in which I am having some View that is textViews ImageViews and MapView and last is listview on the page.

所有这些控件都在滚动视图中.问题在于,当列表视图填充时,滚动滚动视图也会滚动到列表视图.焦点不在页面顶部总是在页面底部.

All these controlls are in a scroll view. The problem is that when the list view populates the scroll scrollview is also scrolls to the listview. The focus is not on the top of page is always on bottom of the page.

我还在XML和代码ListView.setFocusable(false);中将android:focusable="false"用于Listview,但这不起作用,因此请提出任何替代方案.

I also used android:focusable="false" for Listview in xml and in code ListView.setFocusable(false); But this is not working, so please suggest any alternatives.

推荐答案

Vipin是正确的,因为您不能在滚动视图中进行列表视图.您还可以设置一个基于Java的动态布局,它基于您的光标中有多少个项目(用于循环).

Vipin is correct in that you can't do a listview inside a scroll view. You could also setup a tablelayout that is made dynamic in Java based off how many items are in your cursor (for loop).

因此,换句话说,使用滚动视图设置XML.添加将显示在顶部的项目,然后在底部放置表格.用buildRow()用Java构建表.在调用setContentView(R.layout.xmllayout);之后调用它;

So in other words, setup your XML with a scroll view. Add items to it that will show at the top, then at bottom put your table. Build table in Java with buildRow(). Then call it after you call your setContentView(R.layout.xmllayout);

这篇关于将ScrollView聚焦在android中的页面顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆