Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/203.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android ScrollView在结束滚动时添加数据_Android_Scrollview - Fatal编程技术网

Android ScrollView在结束滚动时添加数据

Android ScrollView在结束滚动时添加数据,android,scrollview,Android,Scrollview,我读过很多帖子,但从未找到解决问题的方法,即: 我在ScrollView中有LinearLayout。线性布局包含充气布局。最后我有一个按钮。当用户单击按钮时,它会放大更多布局(添加更多表格行)。现在,我想删除按钮,并在用户滚动到底部时调用其函数 --编辑-- 这是我的部分代码 public void showRows(){ try { mydb = openOrCreateDatabase(DBNAME, Context.MODE_PRIVATE, null);

我读过很多帖子,但从未找到解决问题的方法,即: 我在ScrollView中有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...
        }
    }

}
public void showRows(){
试一试{
mydb=openOrCreateDatabase(DBNAME,Context.MODE_PRIVATE,null);
游标select=mydb.rawQuery(“从事务中选择*”+
“限制”+nRow+”,20“,无效);
如果(选择.moveToFirst()){
做{
LinearLayout项目=(LinearLayout)findViewById(R.id.item);
View child=GetLayoutFlater().inflate(R.layout.child,null);
item.addView(子项);
TextView txt=(TextView)child.findViewById(R.id.txt);
txt.setText(select.getString(0));
}while(选择.moveToNext());
}
}捕获(例外e){
Toast.makeText(getApplicationContext(),“读取错误”,Toast.LENGTH_LONG.show();
}最后{
mydb.close();

如果(nRow+11,我建议在这种情况下使用ListView。您将能够检测最后一项何时显示,并调用与按钮的单击调用相同的方法。
您可以通过调用bMore.setVisibility(View.GONE)来隐藏按钮;

请发布您的代码,这样我就可以使用了。