我想知道我的滚动条指向哪个listview项目,以便当我点击滚动条图像时,我可以显示与listview项目相关的弹出窗口
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
setContentView(R.layout.list);
list=(ListView)findViewById(R.id.list);
adapter=new LazyAdapter(this, mStrings);
list.setAdapter(adapter);
}
public View getView(int position, View convertView, ViewGroup parent) {
View vi=convertView;
if(convertView==null)
vi = inflater.inflate(R.layout.item, null);
TextView text=(TextView)vi.findViewById(R.id.text);;
ImageView image=(ImageView)vi.findViewById(R.id.image);
text.setText("itemitemitemitemitemitemitemitemitemitemitemitemititemitemitemmitetemitemitemitemitemitememitemitemitemiitemitemitemitem "+position);
imageLoader.DisplayImage(data[position], image);
return vi;
}
答案 0 :(得分:0)
您需要实现listview的onScroll方法,如下所示:
YOURLISTVIEW.setOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
//Inside this method you can calculate and can found current position
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
//Inside this method you can calculate and can found current position, here you have firstVisibleitem and total visible item count, so I think using it, you can calculate current position.
}
});
答案 1 :(得分:0)
如果您使用OnItemClickListener
,我认为会更好。当您点击某个位置时,您将确切知道该项目的位置。