Skip to content

Instantly share code, notes, and snippets.

@eef
Created February 22, 2011 20:29
Show Gist options
  • Save eef/839323 to your computer and use it in GitHub Desktop.
Save eef/839323 to your computer and use it in GitHub Desktop.
package com.wellbaked.powerpanel;
// Android SDK Imports
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
// Java SDK Imports
import java.util.HashMap;
public class PowerPanel extends Activity {
// Creation of variable which will be used
private Dispatcher dispatcher;
TextView computer_count;
TextView text_view;
HashMap<String, Integer> actionList;
// Override the oncreate method of the extended Activity
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// The creation of the dispatcher, all UI events will call this
createDispatcher();
// Create a list of objects which will be interacted with
viewObjects();
}
// Method to create an instance of the dispatcher class
private void createDispatcher() {
dispatcher = new Dispatcher(this);
}
// We created a hash map of view objects. String => Object
private void viewObjects() {
actionList.put("computer_count", R.id.computer_count);
}
// Update the choosen object, accepts a string which is used to pull the correct value from the actionList<String, Integer>
private void updateTextView(String tv) {
text_view = (TextView)findViewById(actionList.get(tv));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment