<commit_before>---
layout:     post
title:      Activities, Contexts, and Views
date:       2015-05-08 12:00:19
summary:  An overview of three fundamental Android objects.
categories: android
published: true
---


####Context

####Activity

When an activity is created, one of the first things it does (during its onCreate() method) is setup the initial View.

####View

The View class is fundamental to your app's user interface. A View object can be thought of as rectangular portion of the device screen. It can take up the whole screen, or just a portion of it. Its properties define how that portion will appear to the user. ViewGroup, which is the base class for layouts, is a subclass of View. So are TextView, ImageView, and all of the other widgets. Views can be associated with and integer ID, typically assigned in XML:

{% highlight xml %}

<TextView
    android:id="@+id/hello_world"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello world!"/>

{% endhighlight %}

The View can then be located inside an Activity:

{% highlight java %}

TextView helloWorld = (TextView) findViewById(R.id.hello_world);

{% endhighlight %}<commit_msg>5/8 post<commit_after>---
layout:     post
title:      Activities, Contexts, and Views
date:       2015-05-08 12:00:19
summary:  An overview of three fundamental Android objects.
categories: android
published: true
---


####Context

####Activity

When an activity is created, one of the first things it does (during its onCreate() method) is setup the initial View.

####View

The View class is fundamental to your app's user interface. A View object can be thought of as rectangular portion of the device screen. It can take up the whole screen or just a part of it. Its properties define how that screen portion will appear to the user. ViewGroup, which is the base class for layouts, is a subclass of View. So are TextView, ImageView, and the other widgets. Views can be associated with an integer ID, typically assigned in XML:

{% highlight xml %}

<TextView
    android:id="@+id/hello_world"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello world!"/>

{% endhighlight %}

The View can then be located inside an Activity by its ID:

{% highlight java %}

TextView helloWorld = (TextView) findViewById(R.id.hello_world);

{% endhighlight %}
{'fraction_non_alphanumeric': 0.08492922564529559, 'fraction_numerical': 0.012489592006661115, 'mean_word_length': 4.190064794816415, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3499881', 'n_tokens_mistral': 689, 'n_tokens_neox': 624, 'n_words': 313}