Now, we will see how to insert and use third-party libraries easily. For our scope, we will use a very simple and functional library, which is called RoboGuice 2, and which allows us to inject our view, resource, system service, or any other object into our activity (we call this activity RoboActivity
).
To do this, we have to modify the MainActivity.java
class. This class contains the following code:
package com.androidmavenproject; import roboguice.activity.RoboActivity; import roboguice.inject.ContentView; import roboguice.inject.InjectView; import android.os.Bundle; import android.widget.TextView; @ContentView(R.layout.activity_main) public class MainActivity extends RoboActivity { @InjectView(R.id.text_view) TextView name; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); name.setText("Hello world!"); } }
We take advantage of the functionalities offered by this library to set the content view and inject the...