public class GridViewTextTemplate : System.Web.UI.ITemplate
{
private DataControlRowType templateType
private string columnName
private string Id
public GridViewTextTemplate(DataControlRowType type, string colname, string controlId)
{
templateType = type
columnName = colname
Id = controlId
}
public void InstantiateIn(System.Web.UI.Control container)
{
switch (templateType)
{
case DataControlRowType.Header:
myHeadLiteral.ID = Id
myHeadLiteral.Text = columnName
container.Controls.Add(myHeadLiteral)
break
case DataControlRowType.DataRow:
TextBox txt= new TextBox()
txt.ID = cId
txt.DataBinding += new EventHandler(this.TextBoxDataBinding)
container.Controls.Add(txt)
break
default:
break
}
}
private void TextBoxDataBinding(Object sender, EventArgs e)
{
TextBox txt= (TextBox)sender
GridViewRow row = (GridViewRow)txt.NamingContainer
txt.Text = System.Web.UI.DataBinder.Eval(row.DataItem, columnName).ToString()
}
}
void Page_Load(Object sender, EventArgs e)
{
if (!IsPostBack)
{
TemplateField tf
tf= new TemplateField()
tf.ItemTemplate = new GridViewTextTemplate(DataControlRowType.DataRow, "", "")
tf.HeaderTemplate = new GridViewTextTemplate(DataControlRowType.Header, "", "")
GridView1.Columns.Add(tf)
}
}
1、通过gridview.setOnScrollListener(lisntener)设置滚动监听,判定是否到了底部2、从sdcard读取数据
3、adapter.notifyDataSetChanged() 通知适配器数据变更
这么多图片,小心OOM
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)