[8] use of the injection framework roboguice: (your first injected fragment)

Source: Internet
Author: User

In the previous article, we briefly introduced the use of roboguice ([7] use of the injection framework roboguice :( your first custom binding). Today, let's take a look at the fragment annotation.

(1): Like activity, we can also use annotations in fragment. You need to take the following steps.

①: Compile an inheritance and robofragment fragment;

②: Set your layout (if view injection is used)

③: Inject your view space, resource files (resources), objects, etc.

(2) Example:

public class MyFragment extends RoboFragment {    // Inject your view    @InjectView(R.id.text1) TextView nameTextView;    // Inflate your view as you normally would for any fragment...    @Override    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {        return inflater.inflate(R.layout.my_layout, container, false);    }  }
(3) Compatibility

Currently, roboguice 3.0 supports native and fragment compatibility. The package names are as follows:

    • PackageRoboguice. Fragment(For support fragments)
    • PackageRoboguice. Fragment. Provided(For native Android SDK 11 + fragments)

[8] use of the injection framework roboguice: (your first injected fragment)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.