@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.example); gridview = (PagedDragDropGrid) findViewById(R.id.gridview); ExamplePagedDragDropGridAdapter adapter = new ExamplePagedDragDropGridAdapter(this, gridview); gridview.setAdapter(adapter); gridview.setClickListener(this); gridview.setBackgroundColor(Color.LTGRAY); gridview.setOnPageChangedListener( new OnPageChangedListener() { @Override public void onPageChanged(PagedDragDropGrid sender, int newPageNumber) { Toast.makeText( ExampleActivity.this, "Page changed to page " + newPageNumber, Toast.LENGTH_SHORT) .show(); } }); }
@Override protected void onSaveInstanceState(Bundle outState) { outState.putInt(CURRENT_PAGE_KEY, gridview.currentPage()); super.onSaveInstanceState(outState); }
@Override public void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); int savedPage = savedInstanceState.getInt(CURRENT_PAGE_KEY); gridview.restoreCurrentPage(savedPage); }