Grabbing Click Events In Droid App

Hello everyone,

Over the past few weeks I have stepped into the deep end of a market that I felt was up and coming. I decided to write a droid application fresh as a java guy, because I got my new Droid 3. First off, if you have a droid you know why I did this and if you don’t have it, go try one, they are awesome! To start, I had to get thrown into a world of XML oriented UI design which I realized how much I loved from XAML. I ran through a few droid tutorials on the developer site for droid and got myself setup with Eclipse and the droid addins.

My first application, I created a simple timer that had a progress button and updated a progress bar. The idea here was to recreate a classic Progress Quest application that you may or may not know. The nice thing that I found about this whole process was how open the community was and how easy it was to pick up a lot of the concepts. Here is some sample code below that I came up with for getting a hold onto a button click event and some multi threading in Java.

public class DroidQuestActivity extends Activity implements OnClickListener {
    private ToggleButton mApplicationToggleButton;
     /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        setupFormVariables();
    }
    public void setupFormVariables() {
       mApplicationToggleButton = (ToggleButton)findViewById(R.id.ToggleAppButton);
       mApplicationToggleButton.setOnClickListener(this);    }
    }        
    public void onClick(View v) {
       // Do some click events from the button   
   }
}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>