Search in sources :

Example 1 with GridViewAdapter

use of com.daimajia.swipedemo.adapter.GridViewAdapter in project AndroidSwipeLayout by daimajia.

the class GridViewExample method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gridview);
    final GridView gridView = (GridView) findViewById(R.id.gridview);
    final GridViewAdapter adapter = new GridViewAdapter(this);
    adapter.setMode(Attributes.Mode.Multiple);
    gridView.setAdapter(adapter);
    gridView.setSelected(false);
    gridView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

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

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Log.e("onItemClick", "onItemClick:" + position);
        }
    });
    gridView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            Log.e("onItemSelected", "onItemSelected:" + position);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
}
Also used : GridViewAdapter(com.daimajia.swipedemo.adapter.GridViewAdapter) AdapterView(android.widget.AdapterView) GridView(android.widget.GridView) GridView(android.widget.GridView) View(android.view.View) AdapterView(android.widget.AdapterView)

Aggregations

View (android.view.View)1 AdapterView (android.widget.AdapterView)1 GridView (android.widget.GridView)1 GridViewAdapter (com.daimajia.swipedemo.adapter.GridViewAdapter)1