【发布时间】:2014-03-18 03:16:29
【问题描述】:
我已经阅读了很多帖子,但从未找到解决我的问题的方法: 我在 ScrollView 中有 LinearLayout。 LinearLayout 包含膨胀的布局。最后我有按钮。当用户单击按钮时,它会膨胀更多布局(添加更多表格行)。现在,我想删除按钮并在用户滚动到底部时调用它的函数。
--编辑过--
这是我的代码的一部分...
public void showRows(){
try {
mydb = openOrCreateDatabase(DBNAME, Context.MODE_PRIVATE, null);
Cursor select = mydb.rawQuery("SELECT * from TRANSACTIONS "+
"limit "+nRow+",20", null);
if (select.moveToFirst()) {
do {
LinearLayout item = (LinearLayout)findViewById(R.id.item);
View child = getLayoutInflater().inflate(R.layout.child, null);
item.addView(child);
TextView txt = (TextView) child.findViewById(R.id.txt);
txt.setText(select.getString(0));
} while (select.moveToNext());
}
} catch (Exception e) {
Toast.makeText(getApplicationContext(), "Reading error.", Toast.LENGTH_LONG).show();
} finally {
mydb.close();
if(nRow+11 <= nTotalRows){
LinearLayout item = (LinearLayout)findViewById(R.id.item);
child_more = getLayoutInflater().inflate(R.layout.transaction_more, null);
item.addView(child_more);
bMore = (Button) child_more.findViewById(R.id.bMore);
bMore.setOnClickListener(this);
// on click nRow = nRow + 20 ... and calls again the same function
//TODO...
//...remove button but call more if ScrollView reachs end...
}
}
}
【问题讨论】:
-
请发布您的代码,以便我可以使用。
标签: android scrollview