I have TableLayout in the ScrollView. I add items there in with the method:

    private void appendRows(int start , int end) {
    final TableLayout table = (TableLayout)findViewById(R.id.table);
    for (int i=start; i<=end; i++)
    { 
        TableRow row = new TableRow(this); 

        TextView idText = new TextView(this);

        idText.setText(Integer.toString(forPrint.get(i).getOrderid()));

        idText.setPadding(10, 0, 0, 20);
        idText.setTextColor(Color.BLACK);
        row.addView(idText);

        TextView textOne = new TextView(this);
        textOne.setText(forPrint.get(i).getTitle());
        textOne.setSingleLine(false);
        textOne.setPadding(15, 0, 0, 0);
        textOne.setTextColor(Color.BLACK);
        row.addView(textOne);

        TextView textTwo = new TextView(this);
        textTwo.setText(Float.toString(forPrint.get(i).getPrice()));
        textTwo.setPadding(15, 0, 0, 0);
        textTwo.setTextColor(Color.BLACK);
        row.addView(textTwo);

         TextView textThree = new TextView(this);
         
textThree.setText(forPrint.get(i).getProcess_status().getProccessStatusTitle());
         textThree.setPadding(15, 0, 0, 0);
         textThree.setTextColor(Color.BLACK);
        row.addView(textThree);

       table.addView(row, new TableLayout.LayoutParams()); 
   }
 }

I want to react on user's scroll action and update items in TableLayout 
corresponding to scroll events. For example it should be first 10 items of 
the list when user opens the activity. Then if he scroll down, it should be 
next 10 items of the list. If he scroll up - previous 10 items. I created 
such class for this:

class MyGestureListener extends SimpleOnGestureListener implements 
OnTouchListener
{

public boolean onScroll(MotionEvent e1, MotionEvent e2, float arg2,
        float arg3) {
    mIsScrolling = true;   
    float pos = e2.getY() - e1.getY();
      if (pos<0)
      {
          start +=10;
          end+=10;
      }
      else 
      {
          start -=10;
          end -=10;  

      }

   if (e2.getAction() == MotionEvent.ACTION_UP)
   {
       String message = "Helo";
       Toast toast = Toast.makeText(getApplicationContext(), message, 
Toast.LENGTH_LONG);
        toast.show();
   }
    return true;
}

}

I want to react on scrolling events - detect pos variable after scrolling 
was stopped and update items in TableLayout correspondingly. I tried do it 
with

Scroller scroller = new Scroller(getApplicationContext());
scroller.isFinished();

But it detects very sensitivly and also when scrolling wasn't stopped. So 
works not properly. Also tried to make it with

  gestureListener = new View.OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {

            if (gestureDetector.onTouchEvent(event)){
                Log.i("qew","qwe");
                return true;}


        if(event.getAction() == MotionEvent.ACTION_UP) {
             if(mIsScrolling ) 
             {
                Log.d("qwe","OnTouchListener --> onTouch ACTION_UP");
                mIsScrolling  = false;
                handleScrollFinished();
              }

        }

in my onCreate() method but in some reasons this method can't be called. I 
tried to put there simple Log.i("qew","qwe");

But it wasn't call. Tell how can I implement it. Appreciate your help.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to