如何获取列表行项目(TextView的)身份证件和文字的ListView onScroll在android系统? [英] How to get list row item(textview) id and text in onScroll of Listview in android?
问题描述
我在使用基本适配器来创建自定义列表视图。有列表视图的每行中一个的ImageView和TextView中。我想要做的是,当我的列表视图滚动我想要得到的TextView的列表视图中的firstvisible行的文本,然后我想使TextView的无形的ListView firstvisible行。我怎样才能得到Id和数据列表视图的onScroll方法的看法。
@覆盖
公共查看getView(INT为arg0,查看convertView,ViewGroup中ARG2){
// TODO自动生成方法存根 convertView = LayoutInflater.from(MainActivity.this).inflate(R.layout.list_row,ARG2,FALSE);
TextView的电视=(TextView中)convertView.findViewById(R.id.textViewrow);
tv.setText(位置+ arg0中);
= TV_ITEM电视;
// tv.setTag(位置+ arg0中);
返回convertView;
}@覆盖
公共无效onScroll(AbsListView观点,诠释firstVisibleItem,诠释visibleItemCount,诠释totalItemCount){
// TODO自动生成方法存根
// ViewGroup中的ViewGroup =(ViewGroup中)view.getAdapter()
// .getView(firstVisibleRow,空,查看); //
INT后= lv.getFirstVisiblePosition();
TextView的电视=(TextView中)lv.findViewWithTag(位置+后);
的System.out.println(位置+后);
//视图V = lv.findViewWithTag(位置+后);
// v.findViewById(R.id.textViewrow).gett
//的System.out.println(位置文本+ tv.getText()); /*tv_item.getHitRect(rect2);
如果(Rect.intersects(Rect1的,RECT2)){
Toast.makeText(getApplicationContext(),相交,Toast.LENGTH_LONG).show();
} * / }
我想这问题与<一个连接href=\"http://stackoverflow.com/questions/23782773/how-to-add-sticky-header-in-listview-with-background-image-on-list-row-in-androi/24224737#\">this :)
要解决你的问题我搜索了一点,我发现<一个href=\"http://stackoverflow.com/questions/18463101/get-listview-children-that-are-not-in-view\">this
现在解决您的问题,你必须遵循以下步骤:
您必须让你这样的一个可见行的观点:
....
@覆盖
公共无效onScroll(AbsListView观点,诠释firstVisibleItem,诠释visibleItemCount,诠释totalItemCount){ 查看查看= mListView.getAdapter()getView(firstVisibleItem,空,mListView)。
TextView的mTextView =(TextView中)view.findViewById(R.id.textViewrow);
mTextView.setVisbility(View.GONE);
我希望它可以帮助你,
I have used base adapter in to create a custom listview. There is an ImageView and TextView in each row of listview. What I want to do is that when I scroll listview I want to get the text of textview in firstvisible row of listview and then I want to make the textview invisible of firstvisible row of listview. How can I get Id and data of a view in onScroll method of listview.
@Override
public View getView(int arg0, View convertView, ViewGroup arg2) {
// TODO Auto-generated method stub
convertView = LayoutInflater.from(MainActivity.this).inflate(R.layout.list_row, arg2, false);
TextView tv = (TextView)convertView.findViewById(R.id.textViewrow);
tv.setText("position " + arg0);
tv_item = tv;
// tv.setTag("position " + arg0);
return convertView;
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
// TODO Auto-generated method stub
// ViewGroup viewGroup = (ViewGroup) view.getAdapter()
// .getView(firstVisibleRow, null, view);//
int post = lv.getFirstVisiblePosition();
TextView tv = (TextView)lv.findViewWithTag("position " + post);
System.out.println("position " + post);
// View v= lv.findViewWithTag("position " + post);
// v.findViewById(R.id.textViewrow).gett
// System.out.println("position text" + tv.getText());
/*tv_item.getHitRect(rect2);
if (Rect.intersects(rect1, rect2)) {
Toast.makeText(getApplicationContext(), "intersected", Toast.LENGTH_LONG).show();
}*/
}
I guess this problem is connected with this :)
To resolve your problem I searched a little and I found this
Now to fix your problem you have to follow these steps:
You have to get the View of your first visible row like this:
....
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
View view = mListView.getAdapter().getView(firstVisibleItem, null, mListView);
TextView mTextView = (TextView) view.findViewById(R.id.textViewrow);
mTextView.setVisbility(View.GONE);
I hope it helps you,
这篇关于如何获取列表行项目(TextView的)身份证件和文字的ListView onScroll在android系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!