您好,我正在使用演示應用程序,我正在使用listview
和自定義適配器。我想這樣做,當我滾動列表時,當你的位置爲2或3,那麼該行應該在屏幕頂部意味着前一行應該完全隱藏。如何將第二行的列表視圖滾動到屏幕頂部
例子中,我在第一行第一次開始滾動列表視圖,然後來到第二時getview
電話與當時的位置2
列表應只在屏幕上排2的展現。我如何實現這一目標?請協助。
當我滾動時看到屏幕截圖,當我甚至移動到第2行時出現兩行,然後第一行也出現,直到我手動向上移動列表。
@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;
}
在此先感謝。
+1謝謝我會嘗試你的方法。似乎沒問題 –