You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: concept_lessons/_android_intent.html.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,6 +52,9 @@ This is a simple example of an share Android Intent. This is typically used when
52
52
53
53
Let us now observe a couple of examples to see how Intent works, how you pass data and how you use Implicit Intents to delegate responsibilities to other apps.
54
54
55
+
<divclass="ac">
56
+
<%= link_to "Go to hands on tutorial on Intent", app_tutorial_module_with_token_path("twitter", LessonModule.find_by_lesson_number(42).lesson.token), class: "btn btn-success btn-large" %>
Copy file name to clipboardExpand all lines: concept_lessons/_android_introduction.html.md
+10-2Lines changed: 10 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,10 @@ This is usually referred to as the launcher Activity or the main Activity too.
32
32
33
33
* Every Android app has a Manifest.xml where all Activites are defined and one Activity is marked as Main Activity. One of the most common error developers commit when they start with Android development is forgetting to add a new Activity in Mainfest.xml file.
34
34
35
-
As a developer, Activity is a Java class file where you write the logic. Activity does not include the UI. Rather, one of the things you need to write in your Activity logic is - which UI to show.
35
+
As a developer, Activity is a Java class file where you write the logic. Activity does not include the UI. Rather, one of the things you need to write in your Activity logic is - which UI to show. <br/>
36
+
<divclass="ac">
37
+
<%= link_to "Go to hands on tutorial on Acitivity", app_tutorial_module_with_token_path("twitter", LessonModule.find_by_lesson_number(4).lesson.token), class: "btn btn-success btn-large" %>
38
+
</div>
36
39
37
40
## User Interface / Views
38
41
@@ -62,7 +65,9 @@ UI is defined as XML. The top XML element is a Layout element . Inside it, there
62
65
</LinearLayout>
63
66
64
67
You may read more about Layouts & Views in our <%= link_to "Layout Concept Lesson", android_concept_lesson_path("android-layout") %> & <%= link_to "View Concept Lesson", android_concept_lesson_path("android-views") %>.
65
-
68
+
<divclass="ac">
69
+
<%= link_to "Go to hands on tutorial on Android UI", app_tutorial_module_with_token_path("twitter", LessonModule.find_by_lesson_number(4).lesson.token), class: "btn btn-success btn-large" %>
70
+
</div>
66
71
## Intents
67
72
68
73
To move from one Activity to another (or one screen to another), on user interaction like click of a button or click of a notification item, Intents are used. It is possible to pass data including whole objects with Intent. Using Intent you can also open another Android application.
@@ -73,6 +78,9 @@ With Activity, Views and Intent; you can create a basic Android app. Lots of app
73
78
74
79
Let’s look into some of the advanced Android concepts.
75
80
81
+
<divclass="ac">
82
+
<%= link_to "Go to hands on tutorial on Intents", app_tutorial_module_with_token_path("twitter", LessonModule.find_by_lesson_number(42).lesson.token), class: "btn btn-success btn-large" %>
83
+
</div>
76
84
## Services
77
85
78
86
Have you ever listened to Music on your phone? Have you observed that the music continues to play in the background when you go to the home screen from the Music app or close the app?
<%= link_to "Go to hands on tutorial on Android UI", app_tutorial_module_with_token_path("twitter", LessonModule.find_by_lesson_number(4).lesson.token), class: "btn btn-success btn-large" %>
105
+
</div>
102
106
103
107
## Android Relative Layout
104
108
@@ -108,6 +112,7 @@ Relative layout is one of the basic layouts available to design UI in Android. I
108
112
109
113
In this layout, you can specify the child layouts w.r.t its sibling or parent. One or more of the following attributes must be set for every view. Otherwise, the views will be rendered one over another in the **top left** region of the RelativeLayout.
110
114
115
+
111
116
### Position relative to container/parent
112
117
113
118
<br/>
@@ -126,6 +131,7 @@ To position an element at the horizontal center, **layout_centerHorizontal** is
126
131
127
132
Similarly, **layout_centerVertical** positions the element vertically at the center. **layout_centerInParent** is layout_centerVertical & layout_centerHorizontal combined.
128
133
134
+
129
135
### Position relative to sibling
130
136
131
137
You can position an element relative to another element in the layout. To refer to an element, it must have a unique ID. This can be assigned using the **android:id** attribute. The attribute can be used to reference the child element against which the positioning needs to be done. More about ids are discussed in the later part of this article.
@@ -134,6 +140,8 @@ You can position an element relative to another element in the layout. To refer
134
140
135
141
Apart from it, there is **layout_above & layout_below**. The names are self explanatory.
136
142
143
+
144
+
137
145
### Android Relative Layout Example
138
146
139
147
[Download this sample project](https://github.com/codelearn-org/android-relative-layout-example/archive/master.zip) , import in Eclipse & navigate to [activity_relative_layout.xml](https://github.com/codelearn-org/android-relative-layout-example/tree/master/res/layout) file as shown in the screenshot below.
@@ -191,6 +199,10 @@ The date field '26 Nov 2013' is again a TextView element aligned to the right of
191
199
.
192
200
/>
193
201
202
+
<divclass="ac">
203
+
<%= link_to "Go to hands on tutorial on Android UI", app_tutorial_module_with_token_path("twitter", LessonModule.find_by_lesson_number(4).lesson.token), class: "btn btn-success btn-large" %>
204
+
</div>
205
+
194
206
## Choosing between Linear & Relative Layout
195
207
196
208
An important consideration when dealing with layout elements is when is it good to use which layout element. The **LinearLayout** is optimized for
@@ -314,6 +326,10 @@ This behavior is similar to how HTML table behaves.
314
326
<br/>
315
327
316
328
329
+
<divclass="ac">
330
+
<%= link_to "Go to hands on tutorial on Android UI", app_tutorial_module_with_token_path("twitter", LessonModule.find_by_lesson_number(4).lesson.token), class: "btn btn-success btn-large" %>
331
+
</div>
332
+
317
333
## Invoking Layout from Activity
318
334
319
335
In each demo we have created a layout and now let us see how this can be used in the Activity. Images, layout files and other application assets stored in the **res** folder are referred as resources in Android. The Android framework creates a unique id for each resource and this exact id can be used to refer to these resources.
@@ -366,3 +382,4 @@ You can specify width and height with exact measurements, though you probably wo
366
382
* match_parent (referred as fill_parent in API Level 8 and lower) tells your view to become as big as its parent view group will allow.
367
383
368
384
In general, specifying a layout width and height using absolute units such as pixels is not recommended. Instead, using relative measurements such as density-independent pixel units (dp), wrap_content, or fill_parent, is a better approach, because it helps ensure that your application will display properly across a variety of device screen sizes.
Copy file name to clipboardExpand all lines: concept_lessons/_android_listview.html.md
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -133,6 +133,9 @@ If you notice in the above example, we have used Android.R.Layout item. This is
133
133
* simple_list_item_single_choice : A List Item with a radio button after textView. You can use this when you want to get a choice from the user.
134
134
* simple_list_item_multiple_choice: A List Item with a Check Box after textview. You can use this when you want to get multiple choices from the user.
135
135
136
+
<divclass="ac">
137
+
<%= link_to "Go to hands on tutorial on List View", app_tutorial_module_with_token_path("twitter", LessonModule.find_by_lesson_number(43).lesson.token), class: "btn btn-success btn-large" %>
138
+
</div>
136
139
137
140
##Custom ListView with BaseAdapter
138
141
@@ -408,6 +411,9 @@ This is how the ListView will look when you run it:
<%= link_to "Go to hands on tutorial on Custom List View", app_tutorial_module_with_token_path("twitter", LessonModule.find_by_lesson_number(43).lesson.token), class: "btn btn-success btn-large" %>
416
+
</div>
411
417
412
418
##ListView Click Listener
413
419
@@ -444,6 +450,9 @@ This is how our click listener looks like :
444
450
445
451
Now you get a fair understanding of how ListView works in Android. Let's See Some more tricks which can help you
446
452
453
+
<divclass="ac">
454
+
<%= link_to "Go to hands on tutorial on List View Click Listener", app_tutorial_module_with_token_path("twitter", LessonModule.find_by_lesson_number(43).lesson.token), class: "btn btn-success btn-large" %>
455
+
</div>
447
456
448
457
##ListActivity
449
458
@@ -493,3 +502,4 @@ You can view the ListActivity example in the sample project that you downloaded.
493
502
>Watchout: ListActivity works well if you have only single ListView. In case you have more than one Android listview, you need to put extra code for the other ListView to work.
494
503
495
504
You can download the sample app from [here](https://github.com/pranayairan/Code-Learn-Android-Example/tree/master/CodeLearnListExample)
Copy file name to clipboardExpand all lines: concept_lessons/_android_views.html.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -292,6 +292,9 @@ Add listener
292
292
});
293
293
In the above code, you add a click listener to the button. Whenever the button is clicked , the onclick method of button is called.
294
294
295
+
<divclass="ac">
296
+
<%= link_to "Go to hands on tutorial on Click Listener", app_tutorial_module_with_token_path("twitter", LessonModule.find_by_lesson_number(41).lesson.token), class: "btn btn-success btn-large" %>
297
+
</div>
295
298
###Code
296
299
This is how a button will look in XML code
297
300
@@ -521,6 +524,10 @@ The ListView is widely used in android applications. A simpler example of list v
521
524
> Listview is a complex UI pattern, and we have a separate section about listview. You can read more about list view in ListView Section
522
525
523
526
527
+
<divclass="ac">
528
+
<%= link_to "Go to hands on tutorial on ListView", app_tutorial_module_with_token_path("twitter", LessonModule.find_by_lesson_number(43).lesson.token), class: "btn btn-success btn-large" %>
529
+
</div>
530
+
524
531
##GridView
525
532
526
533
###What
@@ -633,3 +640,4 @@ This is how our complete scroll view will look
633
640
</ScrollView>
634
641
635
642
Android has a lot of UI elements which are designed for specific purposes, in this chapter we tried to cover some of the most used UI elements. If you want to read more about other UI controls, you can go to [this link](http://developer.android.com/guide/topics/ui/index.html)
0 commit comments