Exemplo n.º 1
0
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   super.onCreateOptionsMenu(menu);
   // Inflate the menu; this adds items to the action bar if it is present.
   getMenuInflater().inflate(R.menu.gallery, menu);
   menu.getItem(4).setIcon(R.drawable.funzoneimg_pressed);
   return true;
 }
Exemplo n.º 2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_gallery);

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);

    actionBar.setCustomView(R.layout.action_gallery);

    gallaryArr = STgallery.getInstance();
    gallaryArr.clear();

    fillData();

    final ImageButton homeButton = (ImageButton) findViewById(R.id.home_btn_gallery);

    homeButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            // Switching to home screen
            Intent intent = new Intent(GalleryActivity.this, HomeActivity.class);
            startActivity(intent);
          }
        });
    final ImageButton editButtonCustom = (ImageButton) findViewById(R.id.gallery_editBtn);
    editButtonCustom.setOnClickListener(
        new View.OnClickListener() {

          public void onClick(View v) {
            editButtonCustom.setVisibility(View.INVISIBLE); // set invisible
            editButtonCustom.setClickable(false);
            editButtonCustom.setFocusable(false);

            for (int i = 0; i < adapter.getCount(); i++) {
              ((CheckBox) gv.getChildAt(i).findViewById(R.id.gallery_checkBox_item))
                  .setVisibility(0); // show all checkbox
            }

            final ImageButton deleteButtonCustom =
                (ImageButton) findViewById(R.id.gallery_deleteBtn);
            deleteButtonCustom.setVisibility(0); // set visible
            deleteButtonCustom.setClickable(true);
            deleteButtonCustom.setFocusable(true);

            deleteButtonCustom.setOnClickListener(
                new View.OnClickListener() {

                  public void onClick(View v) {
                    deleteCheckedItems();
                    for (int i = 0; i < adapter.getCount(); i++) {
                      ((CheckBox) gv.getChildAt(i).findViewById(R.id.gallery_checkBox_item))
                          .setVisibility(4); // hide all check boxes
                    }
                    deleteButtonCustom.setVisibility(4); // set invisible again
                    deleteButtonCustom.setClickable(false);
                    deleteButtonCustom.setFocusable(false);
                    editButtonCustom.setVisibility(0); // set visible again
                    editButtonCustom.setClickable(true);
                    editButtonCustom.setFocusable(true);
                  }
                });
          }
        });
    final ImageButton takeApic = (ImageButton) findViewById(R.id.gallery_camBtn);

    takeApic.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            // Switching to home screen
            dispatchTakePictureIntent();
          }
        });

    gv = (GridView) findViewById(R.id.gallery_gridView);
    gv.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> arg0, View view, int position, long id) {
            openPicDialog(position);
          }
        });

    adapter = new CustomAdapter(this, R.layout.gallery_item, gallaryArr);
    gv.setAdapter(adapter);
  }
Exemplo n.º 3
0
 @Override
 protected void onResume() {
   super.onResume();
   adapter.notifyDataSetChanged();
 }