Get Current View

Source: Internet
Author: User

It is still very useful to layoutinflater this class in real-world development, which acts like Findviewbyid (). The difference is that Layoutinflater is used to find the XML layout file under res/layout/and is instantiated, while Findviewbyid () is looking for specific widget controls (such as button, TextView, and so on) under the XML layout file.

Specific role: 1, for a non-loaded or want to dynamically load the interface, you need to use Layoutinflater.inflate () to load, 2, for an already loaded interface, you can use Activiyt.findviewbyid () method to obtain the interface elements. Layoutinflater is an abstract class that is declared in the document as follows: Public abstract class Layoutinflater extends object obtains three ways of Layoutinflater instance 1. Layoutinflater inflater = Getlayoutinflater ();//Invoke Activity's Getlayoutinflater () 2.  Layoutinflater Inflater = layoutinflater.from (context); 3. Layoutinflater Inflater = (layoutinflater) context.getsystemservice (Context.layout_inflat Er_service);
  View view = Layoutinflater.from (context). Inflate (R.layout.activity_float,                null);

Get Current View

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.