0

ギャラリーをスクロールしている間、最後のアイテムがスクロールされ、左マージンで停止します。最後の項目を画面右端で止めたい。画面に一度に 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;
}
4

1 に答える 1

0

@Rekha position = lastitem - 1 element の場合、その方向へのスクロール機能を停止する必要があると思います。Gallery インスタンス ( gallery.getSelectedItemPosition() ) と onscrollistener を介してそれを行うことができます。

ところで、これは以前の「リストビューでギャラリーを再起動する位置」の問題を解決しますか? ギャラリーホルダーを使用すると、リスト内でギャラリーが繰り返される同様の問題があります。

于 2012-06-29T08:25:00.630 に答える