将焦点从TableLayout Android中的具体的TableRow [英] Set focus to the specific TableRow from the TableLayout in Android

查看:393
本文介绍了将焦点从TableLayout Android中的具体的TableRow的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个tablelayout它包含一行2 textviews。
我的所有行通过活动动态添加和我的表是滚动视图。因此,当行添加表滚动起来一步一步来。

I have one tablelayout and it contains 2 textviews in one row. All my rows are added dynamically through the activity and my table is in scrollview. So, as rows are added table is scrolled up step by step.

我也能够从tablelayout维护所有创建并添加行ID。

I am also able to maintain all created and added row ids from the tablelayout.

我要跳回到由用户指定的行号。
让我们说,用户给5作为行号。所以,我的表应在第5行,这样一行来到屏幕视图,用户可以看到第5行的内容。要向上滚动

I want to jump back to the row number specified by user. Let us say, user gives 5 as a row number. So, my table should be scrolled up at row number 5 so that row comes on the screen view and user can see the content of the 5th row.

我2浪迹天涯得到解决这一点,但没有得到任何的方法来实现这一目标。

I am wandering from 2 days to get solution for this, but not getting any method to achieve this.

有没有人有解决方案呢?

Does anyone have solution for it?

推荐答案

要得到它的滚动叫<一个href=\"http://developer.android.com/reference/android/view/View.html#requestRectangleOnScreen%28android.graphics.Rect%29\"相对=nofollow> TableRow.requestRectangleOnScreen() (替身的TableRow在你的code实际的TableRow对象)。

To get it to scroll call TableRow.requestRectangleOnScreen() (substitute "TableRow" with the actual TableRow object in your code).

您可以使用矩形坐标东西(如0,0,0,0),但我相信使用像矩形(0,0,TableRow.getWidth(),TableRow.getHeight() )将确保全行滚动所以它完全在屏幕上。

You can use anything for the rectangle coordinates (like 0,0,0,0) but I believe using something like Rect(0, 0, TableRow.getWidth(), TableRow.getHeight()) will make sure the whole row is scrolled so it's fully on screen.

其实任何View对象支持 requestRectangleOnScreen()所以玩它。

Actually any View object supports requestRectangleOnScreen() so play around with it.

这篇关于将焦点从TableLayout Android中的具体的TableRow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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