Search in sources :

Example 1 with DynamicGridView

use of com.marshalchen.common.uimodule.dynamicgrid.DynamicGridView in project UltimateAndroid by cymcsg.

the class DynamicGridActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.dynamic_grid_view_activity_grid);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    gridView = (DynamicGridView) findViewById(R.id.dynamic_grid_view);
    gridView.setAdapter(new CheeseDynamicAdapter(this, new ArrayList<String>(Arrays.asList(Cheeses.sCheeseStrings)), 3));
    gridView.setVerticalScrollBarEnabled(false);
    //      gridView.setEnabled(false);
    //        add callback to stop edit mode if needed
    gridView.setOnDropListener(new DynamicGridView.OnDropListener() {

        @Override
        public void onActionDrop() {
            gridView.stopEditMode();
        }
    });
    //        gridView.setOnTouchListener(new View.OnTouchListener() {
    //            @Override
    //            public boolean onTouch(View v, MotionEvent event) {
    //                if (gridView.isEditMode()) {
    //                    gridView.stopEditMode();
    //                }
    //                return false;
    //            }
    //        });
    gridView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            gridView.startEditMode();
            return false;
        }
    });
    gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Toast.makeText(DynamicGridActivity.this, parent.getAdapter().getItem(position).toString() + "  " + gridView.isEditMode(), Toast.LENGTH_SHORT).show();
        }
    });
}
Also used : ArrayList(java.util.ArrayList) DynamicGridView(com.marshalchen.common.uimodule.dynamicgrid.DynamicGridView) View(android.view.View) AdapterView(android.widget.AdapterView) DynamicGridView(com.marshalchen.common.uimodule.dynamicgrid.DynamicGridView) AdapterView(android.widget.AdapterView) ActionBar(android.support.v7.app.ActionBar)

Aggregations

ActionBar (android.support.v7.app.ActionBar)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 DynamicGridView (com.marshalchen.common.uimodule.dynamicgrid.DynamicGridView)1 ArrayList (java.util.ArrayList)1