Native Mobile Development by Mike Dunn & Shaun Lewis
Author:Mike Dunn & Shaun Lewis [Mike Dunn]
Language: eng
Format: epub
Publisher: O'Reilly Media, Inc.
Published: 2019-11-24T16:00:00+00:00
We finally have a usable layout, in the resources file, pre-compiled and ready to go. How do we use it? Well, there are a few ways, some of which we’ll touch on in the next chpater, UI Controllers. For now, let’s concentrate on a couple common approaches, on touch on a couple less common:
Set the layout as the root view of your Activity. Simply call Activity.setContentView and pass the resource id of your layout. In this example:
public class MyActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.my_activity); } }
That’s it! When MyActivity starts, you’ll immediately see the view tree described in the layout XML file.
Add it to an existing view tree. If you’ve already set up a view tree in any other way, you can add or remove View instances using ViewGroup methods pretty easily. For example, ViewGroup.addView and ViewGroup.removeView. This works great for progrmmatically created views, but we can get access to layout inflation explicitly as well. There’s a system service that will do that for us, and there are 2 identical ways to get a reference to that service:
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(6250)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(5957)
Kotlin in Action by Dmitry Jemerov(4638)
React Native - Building Mobile Apps with JavaScript by Novick Vladimir(2340)
Learning Angular - Second Edition by Christoffer Noring(2168)
Pride and Prejudice by Jane Austen(2096)
Mobile Forensics Cookbook by Igor Mikhaylov(1814)
Computers For Seniors For Dummies by Nancy C. Muir(1769)
Bulletproof Android: Practical Advice for Building Secure Apps (Developer's Library) by Godfrey Nolan(1671)
Building Android UIs with Custom Views by Raimon Ràfols Montané(1621)
Android Development with Kotlin by Marcin Moskala & Igor Wojda(1616)
Building Progressive Web Apps: Bringing the Power of Native to the Browser by Ater Tal(1534)
1936941139 (N) by Bob Rosenthal(1502)
Android App Development by Franceschi Hervé J.;(1497)
Ember.js in Action by Joachim Haagen Skeie(1469)
Hands-On Internet of Things with MQTT by Tim Pulver(1417)
Hands-On Design Patterns with React Native by Mateusz Grzesiukiewicz(1407)
Practical Industrial Internet of Things Security by Sravani Bhattacharjee(1317)
Voice User Interface Projects by Henry Lee(1270)