Android Open Source - Android-ToolbarButton Main Activity






From Project

Back to project page Android-ToolbarButton.

License

The source code is released under:

This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a co...

If you think the Android project Android-ToolbarButton listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.example.example;
/*from   w w w.ja  v  a 2 s . c  o m*/
import java.util.Timer;
import java.util.TimerTask;

import toolbarelements.RefreshButton;
import toolbarelements.ToolBarButton;
import android.app.Activity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;

public class MainActivity extends Activity
{
  protected void onCreate(Bundle savedInstanceState)
  {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Toolbar toolbar = (Toolbar) findViewById(R.id.custom_toolbar);
    toolbar.setTitle("Agenda");

    addButtons(toolbar);
  }

  ToolBarButton refreshButton;
  private void addButtons(Toolbar toolbar)
  {
    refreshButton = new RefreshButton(this, R.drawable.ic_action_refresh);
    refreshButton.addToToolbar(toolbar);
    refreshButton.setOnClickListener(new OnClickListener()
    {
      public void onClick(View v)
      {
        refreshButton.startAnimation(refreshButton.rotation);
        Timer t = new Timer();
        t.schedule(new TimerTask()
        {
          public void run()
          {
            refreshButton.cancelAnimation();
          }
        }, 2000);
      }
    });
    
    ToolBarButton settingsButton = new ToolBarButton(this, R.drawable.ic_action_settings);
    settingsButton.addToToolbar(toolbar, Gravity.LEFT);
  }
}




Java Source Code List

com.example.example.MainActivity.java
toolbarelements.RefreshButton.java
toolbarelements.ToolBarButton.java
toolbarelements.ToolBarButton.java