Skip to content
tylertreat edited this page Dec 31, 2012 · 6 revisions

InfinitumActivity is an extension of Android's Activity which takes care of framework initialization, provides support for resource injection and event binding, and exposes an InfinitumContext.

When building an Activity that relies on Infinitum, it's typically good practice to extend InfinitumActivity rather than manually configuring the framework through the ContextFactory. InfinitumActivity also allows you to perform bean autowiring within the Activity 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.

InfinitumActivity Example

@InjectLayout(R.layout.my_layout)
public class MyActivity extends InfinitumActivity {

    @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);
        InfinitumContext context = getInfinitumContext();
        mMyBean.doStuff(context);
    }

    private void buttonClicked(View view) {
        Toast.makeText(this, "Button clicked: " + mMyString, Toast.LENGTH_LONG).show();
    }

}

Clone this wiki locally