Reputation: 34497
Hello I am working on demo application where I am using listview
and custom adapter. I want to do that when I scroll the list when you come at position to 2 or 3 then that row should be on top of the screen means previous row should be hide completely.
Example I am on first row first time and started to scroll listview then comes to second when getview
call with position 2
then list should only show of row 2 on the screen. How I can achieve this ? Please assist.
See screenshot when I scroll then both rows appear when I even move to row 2 then first row also appears until I move up list manually.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView == null) {
LayoutInflater mInflator = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = mInflator.inflate(R.layout.home_list_item, parent, false);
}
TextView mChapterContent = (TextView) convertView.findViewById(R.id.contentTextView);
// get the data from verse instance
Verse verse = rowItem.get(position);
// setting the content
mChapterContent.setText(Html.fromHtml("<html><body style=\"text-align:justify\">" + verse.getText() + "</body></html>"));
return convertView;
}
Thanks in advance.
Upvotes: 0
Views: 863
Reputation: 17401
Judging from the state, it looks to me as a good use-case of Vertical View pager.
Checkout these likes:
https://github.com/JakeWharton/Android-DirectionalViewPager/
Upvotes: 2