Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #34721

Re: A simpler DOM in JS

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: A simpler DOM in JS
Date 2018-02-08 01:47 +0100
Organization PointedEars Software (PES)
Message-ID <2435608.mvXUDI8C0e@PointedEars.de> (permalink)
References (3 earlier) <1fcf518b-5771-46ba-885d-3565ece3ca42@googlegroups.com> <2311948.Lt9SDvczpP@PointedEars.de> <d3999433-1049-4c21-9981-167bd5f5b88c@googlegroups.com> <1944765.Mh6RI2rZIc@PointedEars.de> <1726220a-10da-4d5a-9ce6-c716290cf571@googlegroups.com>

Show all headers | View raw


Michael Haufe (TNO) wrote:

> Thomas 'PointedEars' Lahn wrote:
>> Michael Haufe (TNO) wrote:
>> > Thomas 'PointedEars' Lahn wrote:
>> >> [...]
>> >> [Android layout XML]
>> > 
>> > While I like the declarative nature, the use of layout containers I
>> > find iffy. How you do manage dynamic layouts?
>> Depends.  “Dynamic” as in…?
> 
> As in, if I rotate the screen and I want LinearLayout to become
> RelativeLayout, what do I do?

Suppose you have res/layout/activity_main.xml that uses LinearLayout, then 
create res/layout-land/, copy the XML file there (keep the filename), and in 
the copy change LinearLayout to RelativeLayout (but see also 
RecyclerView.LayoutManager subclasses, which work better with listings). 
Now, that does _not_ mean that you have to maintain all the *content* twice 
(or more): you can use *fragments* to include the same content in different 
view groups.  (In the course we learned to use fragments precisely for 
handling landscape mode.)

See also:
<https://developer.android.com/training/basics/supporting-devices/screens.html>
<https://developer.android.com/training/basics/fragments/index.html>

And that is only one of many specializations that you can implement this way 
(which I called “suffixed resource directories” before).

    [One of them that ought also be mentioned is internationalization, which 
     (AISB) would be a PITA if you did in in Java code: just create e.g.
     res/values-fr/strings.xml for the text that should be displayed when
     the user uses the French locale.  If you refer to “@string/…” in your
     layouts, or use getString(R.string.…) throughout your Java code, then
     you may not have to customize anything else (of course, French words
     tend to be longer, so maybe it needs layout tweaking, too).  You can
     give that XML file to your translators, and its structure is very
     simple so they do not have to be coders also, as with GNU gettext. 
     Compare that to language switches in Java code.

     <https://developer.android.com/training/basics/supporting-devices/languages.html>]

This also has to do with what I alluded to earlier: As *you* know, if you 
have XML, you can easily convert it to *anything* using XSLT (even on the 
fly), for example SVG.  I do not know how Android Studio 3.0.1 does the 
visualization, but it also contains a visual layout editor.  If you select 
there that you want a specific landscape layout, for example, then it does 
what I described above (except the last step), and opens the copy.

    [However, if you know in advance that you want displayed properly in 
     both modes, you should first consider using a layout manager that does
     it automatically, such as a ConstraintLayout that uses resources for
     the spacing.]

If you are seriously interested in learning Android development, I can 
highly recommend taking part in the Google Android Dev Challenge:

<https://eu.udacity.com/course/android-developer-nanodegree-by-google--nd801>

The next Challenge should start in November, but you can start the 
nanodegree at any time.  If the Challenge is on, and you submit a convincing 
rationale (like I did), you might even win the scholarship and do not have 
to pay anything for the course and the optional follow-up training that 
Google offers exclusively.

>> Hmmm.  HTML5 validation is actually more strict than HTML < 5 validation,
>> enabled by a grammar that is algorithmic instead of declarative.  But
>> this also makes it more difficult to implement.
> 
> s/algorithmic/procedural

To me, procedural includes the concept of subroutines, which need not be the 
case with parser algorithms like those for HTML5.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

A simpler DOM in JS "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2018-02-03 14:24 -0800
  Re: A simpler DOM in JS Martin Honnen <martin.honnen@gmx.de> - 2018-02-04 14:26 +0100
    Re: A simpler DOM in JS Julio Di Egidio <julio@diegidio.name> - 2018-02-04 06:18 -0800
      Re: A simpler DOM in JS Ken Tilton <kentilton@gmail.com> - 2018-03-05 08:14 -0800
        Re: A simpler DOM in JS Julio Di Egidio <julio@diegidio.name> - 2018-03-08 00:43 -0800
          Re: A simpler DOM in JS Ken Tilton <kentilton@gmail.com> - 2018-03-08 05:57 -0800
            Re: A simpler DOM in JS Julio Di Egidio <julio@diegidio.name> - 2018-03-08 07:56 -0800
    Re: A simpler DOM in JS Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-02-05 06:15 +0100
      Re: A simpler DOM in JS "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2018-02-04 23:15 -0800
    Re: A simpler DOM in JS "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2018-02-04 23:06 -0800
  Re: A simpler DOM in JS Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-02-05 05:50 +0100
    Re: A simpler DOM in JS Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-02-05 06:26 +0100
      Re: A simpler DOM in JS "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2018-02-04 23:33 -0800
        Re: A simpler DOM in JS Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-02-05 11:19 +0100
          Re: A simpler DOM in JS Julio Di Egidio <julio@diegidio.name> - 2018-02-05 04:16 -0800
          Re: A simpler DOM in JS "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2018-02-05 10:23 -0800
            Re: A simpler DOM in JS Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-02-05 19:42 +0100
              Re: A simpler DOM in JS Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-02-08 01:46 +0100
              Re: A simpler DOM in JS Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-02-08 01:47 +0100
                Re: A simpler DOM in JS "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2018-02-11 10:27 -0800
                Re: A simpler DOM in JS Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-02-12 04:38 +0100
                Re: A simpler DOM in JS "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2018-02-15 12:19 -0800
                Re: A simpler DOM in JS Julio Di Egidio <julio@diegidio.name> - 2018-02-15 12:43 -0800
                Re: A simpler DOM in JS Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-02-25 19:22 +0100
              Re: A simpler DOM in JS "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2018-02-07 12:51 -0800
                Re: A simpler DOM in JS Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-02-08 02:27 +0100
                Re: A simpler DOM in JS John G Harris <niam@jghnorth.org.uk.invalid> - 2018-02-08 19:21 +0000
            Re: A simpler DOM in JS Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-02-05 19:58 +0100
    Re: A simpler DOM in JS "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2018-02-04 23:30 -0800
      Re: A simpler DOM in JS Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-02-05 19:11 +0100
        Re: A simpler DOM in JS "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2018-02-11 10:16 -0800
          Re: A simpler DOM in JS Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-02-12 04:48 +0100
  Re: A simpler DOM in JS Ken Tilton <kentilton@gmail.com> - 2018-03-05 08:07 -0800
    Re: A simpler DOM in JS "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2018-03-06 17:40 -0800
      Re: A simpler DOM in JS Ken Tilton <kentilton@gmail.com> - 2018-03-07 12:09 -0800

csiph-web