Skip to content

Instantly share code, notes, and snippets.

@levinotik
Created July 2, 2012 15:14
Show Gist options
  • Save levinotik/3033716 to your computer and use it in GitHub Desktop.
Save levinotik/3033716 to your computer and use it in GitHub Desktop.
private static final int FOO_BUTTON_ID = 1;
private static final int BAR_BUTTON_ID = 2;
private ArrayList<View> views = new ArrayList<View>();
public void onCreate(Bundle state) {
View v = findViewById(R.id.myView);
if(myDatabase.contains(foo)) {
Button b = new Button(this);
v.addView(b);
v.setId(FOO_BUTTON_ID);
views.add(b);
} else if(myDatabase.contains(bar)) {
Button b = new Button(this);
v.addView(b)
v.setId(BAR_BUTTON_ID)
views.add(b);
}
for(View v: views) {
if(v.getId==FOO_BUTTON_ID) ((TextView)v).setText("foo");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment