Hey Joop,

I think the problems have less to do with the tutorial more than
possibly not being familiar with Eclipse and Java.
The android beginners tutorials are cued toward those who are already
familiar with both as well as XML, not a beginner to the whole works.

Just like in Java on Eclipse you have to import everything.
Thankfully in Eclipse it is easy enough by right-clicking on the error
message alongside the offending code
and going to the Quick Fix menu and choosing to import if it is an
option which you apparently figured out.
If your just learning Java and Android, Quick fix qill be a good
friend and occasionaly your nemesis as it may sometimes offer to do
stuff that
only makes it all worse (not too often though :) )

as for ...... mTabHost = getTabHost(); ,
the onCreate() method (the area inside the curly brackets) is just a
small portion of code that can be called into action anywhere onCreate
() is called from within the code you write. It just so happens that
onCreate is also called when the application is started up for the
first time as well.

What that code is doing(in an easy to follow analogy) is telling the
computer that the variable mTabHost is equal to the return type of a
different method called
getTabHost. Before assignment to any variable can be made however the
computer must be explicitly told that the variable mTabHost (or any
other variable you chose to use in the future) exists and what type it
is. In android and java this normally happens just after the
declaration of the class like this.....

public class SomeClassName [extends and/or implements some other stuff
after naming it]{
SomeVariableType someVariableName;                 // this is saying
there will be a variable of the type give and then naming that
variable
TabHost mTabHost;                                             // like
above this is saying that there is a variable of type TabHost and it
will be named mTabHost;

// after that you can call the other stuff in onCreate or other
methods

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    mTabHost = getTabHost();                  // this would be OK now
because we told it earlier (before this method was called) that
mTabHost existed to start with
    someVariableName = new SomeVariableType
();                         // this would also be ok as it knows it is
there
    anotherVariableName =
2;                                             //this would NOT work
because we have not told the computer it exists or what it will be
    int yetAnotherVarName = 2;             // this will be ok as we
are declaring and assigning in one line, however the yetAnotherVarName
can only be seen within
                                                         // the
onCreate method, and when the method ends it will cease to exist as
far as the program is concerned
}


}

That is all that was going on in your trouble (well the extremely
simplified version anyway) , as you get used to Java and the Eclipse
development software there are things that will quite quickly become
second nature but if you are trying to learn Android Application
programming with no Java use before, it will be tough but keep with
it. Try looking for good guides for Java and Eclipse and refer to them
often, as you will basically be learning 2 different ways to program
at once. Stick with it though as you figure out each thing 15 others
seem to make instant sense afterward.

Myself, I am familiar with java but have 0 xp with XML, so half of
this is natural for me and the other half makes me want to claw my
eyes out. ( lol XD )

Oh, BTW, my favorite Eclipse trick.....

Highlight a whole page, then press [CTRL] + [SHIFT] + [F]...... indent
correction and variable call simplification (in certain situations
anyway) all at once.

On Apr 15, 10:41 pm, Joop <joopthe...@gmail.com> wrote:
> Hello, all.  First time posting here.  I did as thorough a search as
> my tired eyes would allow me, back and forth to make sure someone had
> already pointed this out.  So I apologize if this issue has been
> discussed before.  I found nothing anywhere to suggest someone else
> had this problem.
>
> First of all, I wanted to learn about using Tab Views in Android.  I
> found this:
>
> http://developer.android.com/guide/tutorials/views/hello-tabwidget.html
>
> "GREAT!" I thought.  Until I copied verbatim the example code and
> layout supplied only to find that Eclipse was NOT happy with my code.
> Alright, so I did some experimentation (wasted time) and finally found
> that the tutorial does not discuss what one needs to IMPORT at the
> beginning of the .java file.
>
> In case you're having this problem, you need to import these at the
> beginning of your source code after package declaration:
>
> import android.app.TabActivity;
> import android.os.Bundle;
> import android.widget.TabHost;
>
> On top of this, the example has this line of code in it:
> mTabHost = getTabHost();
>
> I could not get code to work until I declared what TYPE mTabHost was
> supposed to be, the following allowed my code to work:
>
> TabHost mTabHost = getTabHost();
>
> My question is this:  ->  If the example code is not in error, then
> why could I not make the code work as per the instructions explicitly
> supplied?  Also, how was I supposed to know about importing
> android.widget.TabHost???  I couldn't find that information ANY where
> (and this is supposed to be a beginners guide to Android).  Lastly,
> did I really need to declare mTabHost as being of type TabHost?  The
> example didn't say to do it.
>
> So you see, I'm having trouble finding out why no one else has had
> this problem.  Maybe it's because I am an idiot, and that is perfectly
> fine with me.  But how was I supposed to know where to find the
> answers I needed?  Hopefully this saves some time for others trying to
> learn this.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to