FileDocCategorySizeDatePackage
Gallery1.javaAPI DocAndroid 1.5 API4264Wed May 06 22:41:08 BST 2009com.example.android.apis.view

Gallery1

public class Gallery1 extends android.app.Activity

Fields Summary
Constructors Summary
Methods Summary
public booleanonContextItemSelected(android.view.MenuItem item)

        AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
        Toast.makeText(this, "Longpress: " + info.position, Toast.LENGTH_SHORT).show();
        return true;
    
public voidonCreate(android.os.Bundle savedInstanceState)

        super.onCreate(savedInstanceState);
        setContentView(R.layout.gallery_1);

        // Reference the Gallery view
        Gallery g = (Gallery) findViewById(R.id.gallery);
        // Set the adapter to our custom adapter (below)
        g.setAdapter(new ImageAdapter(this));
        
        // Set a item click listener, and just Toast the clicked position
        g.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView parent, View v, int position, long id) {
                Toast.makeText(Gallery1.this, "" + position, Toast.LENGTH_SHORT).show();
            }
        });
        
        // We also want to show context menu for longpressed items in the gallery
        registerForContextMenu(g);
    
public voidonCreateContextMenu(android.view.ContextMenu menu, android.view.View v, android.view.ContextMenu.ContextMenuInfo menuInfo)

        menu.add(R.string.gallery_2_text);