-
Notifications
You must be signed in to change notification settings - Fork 1
InfinitumListActivity
tylertreat edited this page Dec 31, 2012
·
2 revisions
InfinitumListActivity is an extension of Android's ListActivity which takes care of framework initialization, provides support for resource injection and event binding, and exposes an InfinitumContext.
When building a ListActivity that relies on Infinitum, it's typically good practice to extend InfinitumListActivity rather than manually configuring the framework through the ContextFactory. InfinitumListActivity also allows you to perform bean autowiring within the ListActivity as well as injecting layouts, views, and resources. Lastly, it allows you to bind event listeners to views so that you don't have to implement anonymous inner classes in your code.
@InjectLayout(R.layout.my_layout)
public class MyListActivity extends InfinitumListActivity {
@Autowired
private MyBean mMyBean;
@InjectResource(R.string.my_string)
private String mMyString;
@InjectView(R.id.my_button)
@Bind("buttonClicked")
private Button mMyButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
populateList();
InfinitumContext context = getInfinitumContext();
mMyBean.doStuff(context);
}
private void buttonClicked(View view) {
Toast.makeText(this, "Button clicked: " + mMyString, Toast.LENGTH_LONG).show();
}
// ...
}