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();
}
});
}
Aggregations