This topic is READ ONLY
oppa (5) [Avatar] Offline
The text asks to drag three plain text views into the LinearLayout. On page 22 these have magically converted to EditText, Button and TextView. What potion do I have to drink to make that happen ?
oppa (5) [Avatar] Offline
Re: pg.21 Try it now - Adding the UI widgets
And it goes on. In my auto generated is nothing about fragments. It doesn't look like listing 2.1. So, where do I place the additional code ?

Where did you get Android Studio 0.6.2 ? I'm on arch Linux and 0.4.6 is the version I have, it was updated yesterday.
andy.starr (2) [Avatar] Offline
Re: pg.21 Try it now - Adding the UI widgets
Thanks for pointing out a mistake in the text - for which I apologise.

The mistake is with the second item, which should of course say "Drag a 'Button' widget...". The other two statements in the section, adding a "Plain Text" and a "Plain TextView", are correct and Android Studio should automatically list them in the Component Tree as EditText and TextView respectively. Plain Text is the name Android Studio shows for a generic TextView component (one without an input filter) and likewise the a Plain Textview is a standard TextView that doesn't have any additional settings for font size.

We'll have a think about updating the text to clarify this in later versions.
andy.starr (2) [Avatar] Offline
Re: Android Studio Version
The reference to Android Studio 0.6.2 was a (significant) typo in the first launch of the MEAP, which has been corrected in the currently available version. It should have said 0.3.2.

We took the decision to stick with that version while writing the book due to the numerous changes that were appearing with the frequent updates to Android Studio, and would then make a full set of changes to the text and code to match the version that was available as the book went to press. I see from the release notes (and your post) that Android Studio has changed the code structure dramatically in 0.4.6, and has removed the automatic use of fragments. (Fragments were only forced on us automatically in 0.3.x, and involved a significant rewrite of the book from a pre-MEAP version that used 0.2.x).

For now, please could you install version 0.3.2, which should look like the code examples in the book.

Meanwhile, Chris and I along with our editors will assess our options for the book structure and target version of Android Studio. Thank you for bringing the code changes to our attention.
oppa (5) [Avatar] Offline
Re: Android Studio Version
I can't install older versions of Android Studio. I'm now at 0.5.0. I was trying to adapt the code to the skeleton AS created for me but failed.


import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends ActionBarActivity {

protected void onCreate(Bundle savedInstanceState) {

public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(, menu);
return true;

public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == {
return true;
return super.onOptionsItemSelected(item);

public static class onClickActivity extends Activity implements View.OnClickListener {
TextView greetingLabel;
EditText textInputField;

public View onCreate(Bundle savedInstanceState){
View view = getLayoutInflater().inflate(R.layout.activity_main, false);
greetingLabel = (TextView) view.findViewById(;
textInputField = (EditText) view.findViewById(;
Button copyButton = (Button) view.findViewById(;

return view;

public void onClick(View v){
switch (v.getId()){
case (
String text = textInputField.getText().toString();


Information:Gradle tasks [:app:assembleDebug]
Information:3 errors
Information:4 errors
Information:0 warnings
Information:See complete output in console
Error:Execution failed for task ':app:compileDebugJava'.
> Compilation failed; see the compiler error output for details.
Errorsmilie51, 21) error: onCreate(Bundle) in onClickActivity cannot override onCreate(Bundle) in Activity
return type View is not compatible with void
Errorsmilie52, 44) error: no suitable method found for inflate(int,boolean)
method LayoutInflater.inflate(XmlPullParser,ViewGroup,boolean) is not applicable
(actual and formal argument lists differ in length)
method LayoutInflater.inflate(int,ViewGroup,boolean) is not applicable
(actual and formal argument lists differ in length)
method LayoutInflater.inflate(XmlPullParser,ViewGroup) is not applicable
(actual argument int cannot be converted to XmlPullParser by method invocation conversion)
method LayoutInflater.inflate(int,ViewGroup) is not applicable
(actual argument boolean cannot be converted to ViewGroup by method invocation conversion)
Errorsmilie50, 9) error: method does not override or implement a method from a supertype
oppa (5) [Avatar] Offline
Re: Android Studio Version
Got it. You have to select "Include Blank Fragment" from the drop down menu of the wizard.


The I get the same code skeleton like the one in the book. And it works smilie

chris.loftus (8) [Avatar] Offline
Re: Android Studio Version
Hi Oppa,

Good to see that you managed to get things to work with the 0.5.0 canary release. It is still possible to get 0.3.2 at (although requires a search engine search) but if 0.5.0 works for you, then all the better.

Yes, the problem with the MEAP is the rapid changing of AS versions, and large differences in the tool's UI between versions. At some point we will switch all the chapters to use a new release (non-canary) of AS, but haven't decided when. We will probably strip out the fragments from the early chapters, and bring them in later when they're really needed.


Message was edited by:
sguillory6 (20) [Avatar] Offline
Re: pg.21 Try it now - Adding the UI widgets
Your reference to figure 2.14 is a little premature since you don't mention changing the text on the button to "Copy" until page 22.