滚动图库时,滚动最后一项并停在左边距。我想停止屏幕右边缘的最后一项。我在屏幕上一次显示3个项目,感谢您的任何建议。
public View getView(int position, View convertView, ViewGroup parent) {
Gallery newArticleRow;
LinearLayout layout = (LinearLayout) convertView;
if (layout == null) {
Log.d("in home", "HomeActivityListViewAdapter--- new getView:" + position);
// Inflate the news article row
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.news_articles_row, null);
newArticleRow = (Gallery) convertView
.findViewById(R.id.news_articles_gallery);
DisplayMetrics metrics = new DisplayMetrics();
FishwrapHomeActivity.this.getWindowManager().getDefaultDisplay()
.getMetrics(metrics);
MarginLayoutParams mlp = (MarginLayoutParams) newArticleRow
.getLayoutParams();
mlp.setMargins(-(metrics.widthPixels - (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, 90, FishwrapHomeActivity.this
.getResources().getDisplayMetrics())), mlp.topMargin,
mlp.rightMargin, mlp.bottomMargin);
newArticleRow.setId(position);
newArticleRow.setLayoutParams(mlp);
convertView.setTag(newArticleRow);
convertView.setBackgroundColor(Color.WHITE);
convertView.setFocusableInTouchMode(false);
} else {
Log.d("in home", "HomeActivityListViewAdapter--- old getView:" + position);
// Get the newArticleRow HorizontialListView
newArticleRow = (Gallery) convertView.getTag();
}
// Set the adapter only if the ArticleRow
if (newArticleRow.getAdapter() == null || newArticleRow.getAdapter() != rowAdapters.get(position)) {
newArticleRow.setAdapter(rowAdapters.get(position));
newArticleRow.setOnItemClickListener(itemListener);
}
// Debug.stopMethodTracing();
return convertView;
}
答案 0 :(得分:0)
@Rekha我认为当position = lastitem - 1元素时,你应该停止在该方向上进一步滚动功能。您可能希望通过Gallery实例(gallery.getSelectedItemPosition())和onscrollistener来实现。
<顺便说一句,这是否解决了之前“listview中的位置重启库”问题?我有一个类似的问题,在使用画廊持有人时会在我的列表中重复我的画廊。