<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/">
<channel>
<title>Droidweb.com &#187; Android Developer Center</title>
<atom:link href="http://droidweb.com/tag/android-developer-center/feed/" rel="self" type="application/rss+xml" />
<link>http://droidweb.com</link>
<description>Your source for Android application reviews, programming tips, and other Android advice</description>
<lastBuildDate>Fri, 23 Dec 2011 13:21:14 +0000</lastBuildDate>
<language>en</language>
<sy:updatePeriod>hourly</sy:updatePeriod>
<sy:updateFrequency>1</sy:updateFrequency>
<generator>http://wordpress.org/?v=3.3.1</generator>
<item>
<title>Starting Android Development Part 3: Layout Tutorial 2</title>
<link>http://droidweb.com/2010/01/starting-android-development-part-3-layout-tutorial-2/</link>
<comments>http://droidweb.com/2010/01/starting-android-development-part-3-layout-tutorial-2/#comments</comments>
<pubDate>Wed, 06 Jan 2010 05:43:18 +0000</pubDate>
<dc:creator>Maliek Mcknight</dc:creator>
<category>
<![CDATA[Android Development Corner]]>
</category>
<category>
<![CDATA[Programming]]>
</category>
<category>
<![CDATA[Android Developer Center]]>
</category>
<category>
<![CDATA[development]]>
</category>
<category>
<![CDATA[layout design]]>
</category>
<guid isPermaLink="false">http://www.blog.droidweb.com/?p=1312</guid>
<description>
<![CDATA[As promised, here’s part two of my coverage on layouts in Android.&#160; Lets pick up where we left off, namely we just created a main.xml file for layout of our...]]>
</description>
<content:encoded>
<![CDATA[</p>
<p> <img title="ADC_logo" style="display: block; float: none; margin-left: auto; margin-right: auto" height="253" alt="" src="http://www.blog.droidweb.com/wp-content/uploads/2009/12/ADC_logo1-300x253.png" width="300" />
<p>As promised, here’s part two of my coverage on layouts in Android.&#160; Lets pick up where we left off, namely we just created a main.xml file for layout of our temperature conversion application.</p>
<p>So you know what we’re trying to achieve here, here’s a screenshot of the final product.</p>
<p><a href="http://droidweb.com/wp-content/uploads/2010/01/temp_screen_final.png"><img title="temp_screen_final" style="border-right: 0px; border-top: 0px; display: block; float: none; margin-left: auto; border-left: 0px; margin-right: auto; border-bottom: 0px" height="244" alt="temp_screen_final" src="http://droidweb.com/wp-content/uploads/2010/01/temp_screen_final_thumb.png" width="194" border="0" /></a> </p>
<p>I know what you’re thinking.&#160; That’s not that cute of a layout.&#160; I’ll leave the job of making really pretty layouts to you after you learn the basics.&#160; For now this layout will do to show you how making layouts in Android works.</p>
<p>This layout consists of a TableLayout (A Linear Layout could have done here as well).&#160; Each table row has other items embedded in it.&#160; One row even has a TableLayout embedded within it (just to show that you can do this).&#160; This is a valid layout, but is generally frowned upon, as embedding table layouts within table layouts can lead to slower UI performance in the long run.</p>
<p>Here’s the code for the layout:</p>
<blockquote><p>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;     <br />&lt;TableLayout      <br />android:id=&quot;@+id/widget45&quot;      <br />android:layout_width=&quot;fill_parent&quot;      <br />android:layout_height=&quot;fill_parent&quot;      <br />android:orientation=&quot;vertical&quot;      <br />xmlns:android=&quot;<a href="http://schemas.android.com/apk/res/android&quot;">http://schemas.android.com/apk/res/android&quot;</a>      <br />&gt;      <br />&lt;TextView      <br />android:id=&quot;@+id/title&quot;      <br />android:layout_width=&quot;fill_parent&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:background=&quot;#ff0000ff&quot;      <br />android:padding=&quot;10px&quot;      <br />android:text=&quot;Temperature Conversion App&quot;      <br />android:textSize=&quot;18px&quot;      <br />android:typeface=&quot;sans&quot;      <br />android:textStyle=&quot;bold&quot;      <br />&gt;      <br />&lt;/TextView&gt;      <br />&lt;TableLayout      <br />android:id=&quot;@+id/widget62&quot;      <br />android:layout_width=&quot;319px&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:orientation=&quot;vertical&quot;      <br />&gt;      <br />&lt;TableRow      <br />android:id=&quot;@+id/widget63&quot;      <br />android:layout_width=&quot;149px&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:orientation=&quot;horizontal&quot;      <br />&gt;      <br />&lt;EditText      <br />android:id=&quot;@+id/User_input_F&quot;      <br />android:layout_width=&quot;fill_parent&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:textSize=&quot;18sp&quot;      <br />android:text=&quot; &quot;      <br />&gt;      <br />&lt;/EditText&gt;      <br />&lt;TextView      <br />android:id=&quot;@+id/widget78&quot;      <br />android:layout_width=&quot;wrap_content&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:text=&quot;(ºF)&quot;      <br />&gt;      <br />&lt;/TextView&gt;      <br />&lt;/TableRow&gt;      <br />&lt;TableRow      <br />android:id=&quot;@+id/widget64&quot;      <br />android:layout_width=&quot;fill_parent&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:orientation=&quot;horizontal&quot;      <br />&gt;      <br />&lt;EditText      <br />android:id=&quot;@+id/User_input_C&quot;      <br />android:layout_width=&quot;fill_parent&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:textSize=&quot;18sp&quot;      <br />android:text=&quot; &quot;      <br />&gt;      <br />&lt;/EditText&gt;      <br />&lt;TextView      <br />android:id=&quot;@+id/widget79&quot;      <br />android:layout_width=&quot;wrap_content&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:text=&quot;(ºC)&quot;      <br />&gt;      <br />&lt;/TextView&gt;      <br />&lt;/TableRow&gt;      <br />&lt;TableRow      <br />android:id=&quot;@+id/widget65&quot;      <br />android:layout_width=&quot;fill_parent&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:orientation=&quot;horizontal&quot;      <br />&gt;      <br />&lt;EditText      <br />android:id=&quot;@+id/widget83&quot;      <br />android:layout_width=&quot;fill_parent&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:textSize=&quot;18sp&quot;      <br />android:text=&quot; &quot;      <br />&gt;      <br />&lt;/EditText&gt;      <br />&lt;TextView      <br />android:id=&quot;@+id/User_input_K&quot;      <br />android:layout_width=&quot;wrap_content&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:text=&quot;(ºK)&quot;      <br />&gt;      <br />&lt;/TextView&gt;      <br />&lt;/TableRow&gt;      <br />&lt;/TableLayout&gt;      <br />&lt;TableRow      <br />android:id=&quot;@+id/Conversion&quot;      <br />android:layout_width=&quot;fill_parent&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:orientation=&quot;horizontal&quot;      <br />&gt;      <br />&lt;TextView      <br />android:id=&quot;@+id/conversion&quot;      <br />android:layout_width=&quot;fill_parent&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:text=&quot;Convert to:&quot;      <br />&gt;      <br />&lt;/TextView&gt;      <br />&lt;RadioGroup      <br />android:id=&quot;@+id/widget144&quot;      <br />android:layout_width=&quot;wrap_content&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:orientation=&quot;vertical&quot;      <br />&gt;      <br />&lt;RadioButton      <br />android:id=&quot;@+id/F_Select&quot;      <br />android:layout_width=&quot;fill_parent&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:text=&quot;Fareinheit&quot;      <br />&gt;      <br />&lt;/RadioButton&gt;      <br />&lt;RadioButton      <br />android:id=&quot;@+id/C_Select&quot;      <br />android:layout_width=&quot;wrap_content&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:text=&quot;Celcius&quot;      <br />&gt;      <br />&lt;/RadioButton&gt;      <br />&lt;RadioButton      <br />android:id=&quot;@+id/K_Select&quot;      <br />android:layout_width=&quot;wrap_content&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:text=&quot;Kelvin&quot;      <br />&gt;      <br />&lt;/RadioButton&gt;      <br />&lt;/RadioGroup&gt;      <br />&lt;/TableRow&gt;      <br />&lt;TableRow      <br />android:id=&quot;@+id/widget84&quot;      <br />android:layout_width=&quot;fill_parent&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:orientation=&quot;horizontal&quot;      <br />&gt;      <br />&lt;Button      <br />android:id=&quot;@+id/Calculate&quot;      <br />android:layout_width=&quot;wrap_content&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:text=&quot;Calculate&quot;      <br />&gt;      <br />&lt;/Button&gt;      <br />&lt;/TableRow&gt;      <br />&lt;/TableLayout&gt; </p>
</blockquote>
<p>Note how each element has an id attribute (android:id) and the value of that attribute starts with <a href="mailto:&ldquo;@+id/name">“@+id/<em>name</em>”</a>.&#160; <a href="mailto:&ldquo;@+id/">“@+id/</a>” identifies the name by which you can refer to this<br />
layout element later in your java programming.&#160; Other things to note include:</p>
<ul>
<li><strong>android:layout_width</strong> and <strong>android:layout_height</strong>: Use these to determine how much space an element is going to take up.&#160; These can have two values: wrap_content and fill_parent.&#160; Wrap content means the element will only be as large as it needs to be to display its content.&#160; Fill_parent means the element will fill all available space it can, as determined by the parent element it resides in</li>
<li>To find the attribute applicable to a given layout, check out that layouts documentation at the developer.android.com/reference website.&#160; E.g. the API site for TableLayout is     <br /><a title="http://developer.android.com/reference/android/widget/TableLayout.html" href="http://developer.android.com/reference/android/widget/TableLayout.html">http://developer.android.com/reference/android/widget/TableLayout.html</a>. I usually find the page i need by just searching “android layout” and the name of the element I’m using</li>
</ul>
<p>In the next post of this series I will discuss some common Android layout elements, what they look like, and some of the attributes associated with that element.&#160; Then it’ll be time to connect our layout (frontend) to the logic that makes it work (the backend).&#160; For now check out the code I provided, try to understand how it works, and practice creating your own Android layouts!</p>
]]>
</content:encoded>
<wfw:commentRss>http://droidweb.com/2010/01/starting-android-development-part-3-layout-tutorial-2/feed/</wfw:commentRss>
<slash:comments>2</slash:comments>
</item>
<item>
<title>Starting Android Development Part 3: Layout Tutorial 1</title>
<link>http://droidweb.com/2010/01/starting-android-development-part-3-layout-tutorial-1/</link>
<comments>http://droidweb.com/2010/01/starting-android-development-part-3-layout-tutorial-1/#comments</comments>
<pubDate>Tue, 05 Jan 2010 21:28:48 +0000</pubDate>
<dc:creator>Maliek Mcknight</dc:creator>
<category>
<![CDATA[Android Development Corner]]>
</category>
<category>
<![CDATA[Programming]]>
</category>
<category>
<![CDATA[android]]>
</category>
<category>
<![CDATA[Android Developer Center]]>
</category>
<category>
<![CDATA[development]]>
</category>
<category>
<![CDATA[layout design]]>
</category>
<guid isPermaLink="false">http://www.blog.droidweb.com/?p=1306</guid>
<description>
<![CDATA[Now that I’ve bored you to death with details about how Android programming works, lets actually put something together, shall we?  This post will deal mainly with creating layouts in...]]>
</description>
<content:encoded>
<![CDATA[<p><img style="display: block; float: none; margin-left: auto; margin-right: auto;" title="ADC_logo" src="http://www.blog.droidweb.com/wp-content/uploads/2009/12/ADC_logo1-300x253.png" alt="" width="300" height="253" /></p>
<p>Now that I’ve bored you to death with details about how Android programming works, lets actually put something together, shall we?  This post will deal mainly with creating layouts in Android and will finish up with a sample layout for our Temperature Conversion project.</p>
<p>For what Google has to say about layouts check out their developers site at <a href="http://developer.android.com/guide/topics/ui/index.html">http://developer.android.com/guide/topics/ui/index.html</a>.</p>
<p>Now let me explain a little of what you read.  Layouts for Android screens are described in XML files in your /res/layout/ folder.  The XML file describes a hierarchy of layout elements.  The higher level elements determine the where of your layout and the lower level elements within these elements determine the what of your layout.</p>
<p>Ok that was a mouthful.  Lets look at the <em>simple</em> example Google provided:</p>
<blockquote><p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;utf-8&#8243;?&gt;<br />
&lt;LinearLayout xmlns:android=&#8221;<a href="http://schemas.android.com/apk/res/android&quot;">http://schemas.android.com/apk/res/android&#8221;</a><br />
android:layout_width=&#8221;fill_parent&#8221;<br />
android:layout_height=&#8221;fill_parent&#8221;<br />
android:orientation=&#8221;vertical&#8221; &gt;<br />
&lt;TextView android:id=&#8221;@+id/text&#8221;<br />
android:layout_width=&#8221;wrap_content&#8221;<br />
android:layout_height=&#8221;wrap_content&#8221;<br />
android:text=&#8221;Hello, I am a TextView&#8221; /&gt;<br />
&lt;Button android:id=&#8221;@+id/button&#8221;<br />
android:layout_width=&#8221;wrap_content&#8221;<br />
android:layout_height=&#8221;wrap_content&#8221;<br />
android:text=&#8221;Hello, I am a Button&#8221; /&gt;<br />
&lt;/LinearLayout&gt;</p></blockquote>
<p>The Linear Layout describes the where, e.g. how the elements within this tag are going to be positioned in relation to each other.  TextView and Button are two lower level elements which are UI elements the user will interact with (a box in which to enter data and a clickable button, respectively)</p>
<p>The result of that layout is listed below.  Note the fact that Linear Layout makes the elements line up one below another (We’ll get into the alternative options later).</p>
<p style="text-align: center;"><a href="http://www.blog.droidweb.com/wp-content/uploads/2010/01/Picture 3.png"><img class="aligncenter" style="border: 0pt none; display: block;" src="http://droidweb.com/wp-content/uploads/2010/01/Picture3_thumb.png" border="0" alt="Click Me to Make Me Bigger!" width="244" height="198" /></a></p>
<p>Armed with this knowledge, lets try to make our own Layout.</p>
<ul>
<li>Go to File &gt; New &gt; Other</li>
<li>Click on Android &gt; Android XML file</li>
<li>Click Next</li>
<li>In the resulting screen fill out the following values:</li>
<li>Project: Click Browse and select the project you want to associate this XML file with (for this demonstration it would be whatever you named the temperature conversation application project)</li>
<li>File: Call this file main.xml</li>
<li>Click Layout for the type of resource</li>
<li>Choose Linear Layout for the root element of the XML file</li>
</ul>
<p>Everything should look similar to the screenshot below:</p>
<p><a href="http://droidweb.com/wp-content/uploads/2010/01/Picture5.png"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="Picture 5" src="http://droidweb.com/wp-content/uploads/2010/01/Picture5_thumb.png" border="0" alt="Picture 5" width="244" height="243" /></a></p>
<ul>
<li>Click Finish</li>
</ul>
<p>In the coming posts in this series I will go over an actual layout and discuss some of the common layout elements for Android programs.  Stay Tuned!</p>
]]>
</content:encoded>
<wfw:commentRss>http://droidweb.com/2010/01/starting-android-development-part-3-layout-tutorial-1/feed/</wfw:commentRss>
<slash:comments>0</slash:comments>
</item>
<item>
<title>Starting Android Development Part 2: Project Structure</title>
<link>http://droidweb.com/2010/01/starting-android-development-part-2-project/</link>
<comments>http://droidweb.com/2010/01/starting-android-development-part-2-project/#comments</comments>
<pubDate>Sat, 02 Jan 2010 13:30:00 +0000</pubDate>
<dc:creator>Maliek Mcknight</dc:creator>
<category>
<![CDATA[Android Development Corner]]>
</category>
<category>
<![CDATA[Programming]]>
</category>
<category>
<![CDATA[Andriod]]>
</category>
<category>
<![CDATA[Android Developer Center]]>
</category>
<category>
<![CDATA[developer tips]]>
</category>
<category>
<![CDATA[development]]>
</category>
<category>
<![CDATA[eclipse]]>
</category>
<category>
<![CDATA[SDK]]>
</category>
<category>
<![CDATA[starting]]>
</category>
<guid isPermaLink="false">http://www.blog.droidweb.com/?p=1242</guid>
<description>
<![CDATA[In Part One of Starting Android Development, we discussed setting up your project in Eclipse.  Now it&#8217;s time to explain exactly what’s going on and how Android development works.  This...]]>
</description>
<content:encoded>
<![CDATA[<p><img style="display: block; float: none; margin-left: auto; margin-right: auto;" title="ADC_logo" src="http://www.blog.droidweb.com/wp-content/uploads/2009/12/ADC_logo1-300x253.png" alt="" width="300" height="253" /></p>
<p>In <a href="http://www.blog.droidweb.com/?p=1217">Part One</a> of <em>Starting Android Development</em>, we discussed setting up your project in Eclipse.  Now it&#8217;s time to explain exactly what’s going on and how Android development works.  This information will help you keep things in perspective as you program, and it will help you when it comes to debugging time.</p>
<p>Let&#8217;s take a look at the Eclipse screen after you’ve set up a given project:</p>
<p style="text-align: center;"><a href="http://droidweb.com/wp-content/uploads/2009/12/Picture6.png"><img class="aligncenter" style="display: inline; border: 0px;" title="Picture 6" src="http://droidweb.com/wp-content/uploads/2009/12/Picture6_thumb.png" border="0" alt="Picture 6" width="436" height="309" /></a></p>
<p>For the purposes of this explanation, let&#8217;s look at the directories in the left pane of the Eclipse screen.  Under the name of the project you&#8217;ve just created, you should see several subfolders.  Let&#8217;s explain what they do:</p>
<ul>
<li><strong>src</strong>: This holds the source code for your project.
<ul>
<li><strong>com.droidweb.conversion</strong>: This is the package holding your source code.  Several packages can make up a single project.  This is especially true when you include others&#8217; packages to provide some type of functionality for your program.  For example, in a conversion application I wrote (ConvertAll+), I imported a package to handle different currencies.
<ul>
<li><strong>convert.java</strong>: Inside the package are individual .java files.  This is where the goodies (the source code itself) are.</li>
</ul>
</li>
</ul>
</li>
<li><strong>gen</strong>: This is a folder for automatically generated stuff Android uses to help your program operate properly.  There’s nothing in here that you need to mess with.  It will automatically update itself as necessary.  Sometimes when you import projects and they return errors, the solution is to delete this folder and let Eclipse regenerate it for you . . . but more about that later.
<ul>
<li><strong>com.droidweb.conversion</strong>: This is the package holding automatically generated code corresponding to the package of the same name in the /src/ folder.
<ul>
<li><strong>R.java</strong>: R.java is an automatically created and maintained file that keeps up with the resources your project utilizes.  In a lot of your Android programming, you’re going to use static variables that really translate into numerical (usual hex) values.  R.java makes the translation between these variables and their numerical values.</li>
</ul>
</li>
</ul>
</li>
<li><strong>Android 1.5</strong> (or appropriate Android source version): This contains the actual Android source code on top of which you’re going to build your applications.  As such, I’m not really going to discuss this much.</li>
<li><strong>assets</strong>:  Why, this is what you set your &#8212; oh wait &#8212; wrong thing. . . . Usually you won&#8217;t mess with this folder, but if you have raw files to be read by your application, then they <em>can</em> be put here; but it&#8217;s probably better that it goes in the /res/raw folder.  More about that later.</li>
<li><strong>res</strong>: res stands for resources.  Here is where you put your resources (images, files, etc).
<ul>
<li><strong>drawable</strong>: This is where the images you’re going to use go.  Android supports a variety of image files, including .jpg, .gif (static), png, etc.</li>
<li><strong>layout</strong>: This is where the .xml files describing your program layouts go.  I’ll spend a post on those later.</li>
<li><strong>values</strong>: This is where .xml files defining values can be stored.  An example is a network topography program I worked on.  In the custom view drawing routine, I predefined the colors of good / bad links in a .xml file in the /srv/values folder.</li>
</ul>
</li>
<li><strong>AndroidManifest.xml</strong>: This is the file that will be the source of the most headaches for you (well, starting out it will be . . .).  This is where your project is described in a form that Android devices can understand.  Application permissions, activity descriptions, and more are found here.  This file itself will be the topic of a future post onto itself &#8212; yes, it&#8217;s that important.</li>
</ul>
<p>Next time we&#8217;ll discuss program flow in a typical Android program.</p>
]]>
</content:encoded>
<wfw:commentRss>http://droidweb.com/2010/01/starting-android-development-part-2-project/feed/</wfw:commentRss>
<slash:comments>0</slash:comments>
</item>
</channel>
</rss>
<!-- Served from: blog.droidweb.com @ 2012-02-09 03:43:44 by W3 Total Cache -->
