How do I get the amount of pixels which a user has scrolled in a scroll view. I have a scroll view which contains lot of texts. I also have a button at bottom of the screen. What I want is to change text on the button to the amount of scrolling done in the scroll view.
this is code i am using:
import android.app.Activity;
public class Verbal extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.verbal);
TextView verintro = (TextView) findViewById(R.id.verbalintro);
TextView verqstns = (TextView) findViewById(R.id.verqstns);
....
Button answer= (Button) findViewById(R.id.answernumber);
ScrollView scrollview = (ScrollView) findViewById(R.id.scrollview);
int scrollposition = scrollview.getScrollY();
answer.setText(scrollposition);
}
}
the application crashes. i am doing something wrong. all i want is the text on the button to keep changing as the user scrolls up and down.