View Single Post
  #53  
Old November 8th 18, 07:27 PM posted to comp.mobile.android,alt.comp.freeware,microsoft.public.windowsxp.general
Arlen_Holder
external usenet poster
 
Posts: 96
Default Report: My first "hello world" using Android Studio freeware on Windows worked just fine (in about an hour)

On Thu, 8 Nov 2018 17:45:16 +0000, Bill wrote:

Hi Arlen, It seems to me that the tutorial has mistakes and is
misleading! I think by adjusting my code to yours, I have cleared all
the errors.


Hi Bill,

That's *fantastic* that the code helped you clear the errors!
I'm always all about helping people help each other working together!

Hence, I'm very glad I could help, as that's the whole point of Usenet!
People helping each other, where, in this case, we're both noobs!

I'm not afraid to admit that it took me three or four runs (maybe even
more, as I didn't count them) through the tutorial myself before I had a
successful outcome.

So we're both in the same boat!

[As an aside, the people to be afraid of are the ones who can't admit that
they're noobs!]

import android.content.Intent;


I don't have this import, but maybe that comes later.


I agree these "import" lines are tricky.
I'm not sure what they really mean yet though.

import static android.icu.lang.UCharacter.GraphemeClusterBreak.V ;


The problem with the import lines is that you can accidentally add them
very easily, since the Android Studio practically writes the code for you.

For an example, if you type a letter, and then hit tab, it will auto fill
out a lot of the time (if it matches stuff) and then if you hit return, a
bunch of automatic things just happen. So it's very very very easy to add
stuff you may not have meant to add, simply by hitting simple keys like tab
and return!

I think I realize, looking at what you wrote, is that I gave you my *final*
code, but I should have given you the code at the exact point where you are
in the tutorial.

Can you tell me the link again, so that I'm sure exactly which page in the
tutorial you are stuck at?

o Page 1 of 5: Build your first app
https://developer.android.com/training/basics/firstapp/
o Page 2 of 5: Create an Android project
https://developer.android.com/training/basics/firstapp/creating-project
o Page 3 of 5: Run your app
https://developer.android.com/training/basics/firstapp/running-app
o Page 4 of 5: Build a simple user interface
https://developer.android.com/training/basics/firstapp/building-ui
o Page 5 of 5: Start another activity
https://developer.android.com/training/basics/firstapp/starting-activity

Maybe I can re-run the tutorial and stop at _that_ page for you to show the
code, where we can presume that noobs following in our footsteps will have
the exact same issues that you're having.

I haven't yet tried to progress any further (lack of time - we have a
lot of family matters here), but would be interested to know how, for
example, you came to reverse View and view.


I am also only working on this sporadically. There may be a day or two
between efforts, or maybe only ten minutes between efforts.

I did run a test this morning where it took 26 seconds from the time I hit
run to the time that the display showed up on the Microsoft emulator. I
then ran that test again where the device under test was the phone, which
took about the same amount of time (give or take a second or two).

So, at this stage, I'm going to mostly run on emulation since it clutters
up my extremely neat phone desktop screen otherwise.

The external editor I'm using is Notepad++. I had difficulty making it
the default editor on the Windows 10 machine, but by digging through the
Settings menu to the "Default Options by File type" and then pointing it
to the Notepad++ .exe file.


Ah. My default text editor is gVIM (because I grew up on UNIX), where
Windows just will NOT accept gVim as the default text editor for either XML
or java files!
o What editor do you use to edit "java" & "xml"
http://www.pcbanter.net/showthread.php?t=1106289

Most Windows users seem to be on the same editor you're on, so that's good
for you that you can get a doubleclick to open the files in your editor.

I will try to catch up over the next few days. Many thanks for getting
me past this problem.


If you can find another tutorial for both of us to try, Bill, that would be
useful as we can do it at the same time (where, as a result, anyone reading
this thread, now or in the future, can benefit).

[That's the entire point of Usenet, after all. Helpful collaboration.]

Meanwhile, I ran that Bill Butterfield tutorial (for the third or fourth
time) this morning where I re-did the adder that I had created last time
(but which I had deleted in my clean-slate wipeouts as I organized the
files).

Just as like what happened with the original Google "Hello World" tutorial,
each time I run though this Bill Butterfield tutorial, I get fewer and
fewer and fewer mishaps - and things work faster and faster and faster.

This last rev took less than a half hour (or so ... as I wasn't counting).

Here is a screenshot of the adder app that resulted from that tutorial:
http://www.bild.me/bild.php?file=8515596androidstudio46.jpg

You'll note I positioned the buttons differently but that is just window
dressing. I moved them up because the keyboard kept getting in the way on
the phone (but not in the emulation, oddly enough).

It's the "Android Studio For Beginners Part 1", by Bill Butterfield.
o Published on Jun 13, 2017 (mp4)
o https://youtu.be/dFlPARW5IX8 (part 1 of 4)
===========
Here's the java code (so that you and others can use it directly)
C:\tmp\android\app03\app\src\main\java\com\kiss\ap p03\MainActivity.java
===========
package com.kiss.app03;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Button addBtn = (Button) findViewById(R.id.addBtn);
addBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EditText firstNumEditText = (EditText)
findViewById(R.id.firstNumEditText);
EditText secondNumEditText = (EditText)
findViewById(R.id.secondNumEditText);
TextView resultTextView = (TextView)
findViewById(R.id.resultTextView);

int num1 =
Integer.parseInt(firstNumEditText.getText().toStri ng());
int num2 =
Integer.parseInt(secondNumEditText.getText().toStr ing());
int result = num1 + num2;
resultTextView.setText(result + "");
}
});

}
}
===========
Here's the xml layout (so that you and others can use it directly)
C:\tmp\android\app03\app\src\main\res\layout\activ ity_main.xml
===========
?xml version="1.0" encoding="utf-8"?
android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
tools:layout_editor_absoluteY="81dp"

android.support.constraint.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content
===========

With respect to my positioning the buttons differently from the tutorial:
http://www.bild.me/bild.php?file=8515596androidstudio46.jpg

Two things I learned (which is why I repositioned the buttons):
1. The keyboard acts slightly differently in emulation because the emulator
uses your real keyboard and not a pop-up keyboard (which the phone uses).
2. On the phone, I need a way to make the keyboard go away in the app, so
as to eliminate the step of closing the keyboard manually.
Ads