title: Endless scroll kotlin recycling view/ListView
body: <p>I am desperately trying to implement endless scrolling on an android app using kotlin. All the tutorials are either useless since they dont explain things properly. So for example:
  <a href="https://github.com/chetdeva/recyclerview-bindings" rel="noreferrer">https://github.com/chetdeva/recyclerview-bindings</a> </p>
  
  <p>it looks promising but the author uses phrases like 
  "put this in your BindingAdapter" so i look what this <code>BindingAdapter</code> is, I found a java file but if you insert anything in there I get errors. Its like anything I try fails directly. </p>
  
  <p>The other tutorials are written in java and even with "translate to kotlin" option its useless since the translated code throws 100 errors. </p>
  
  <p>I tried things like :</p>
  
  <pre><code>setContentView(R.layout.activity_main)
      list.layoutManager = LinearLayoutManager(this)
      list.hasFixedSize()
      list.adapter = ListAdapter(this, getLists())
      val list_view: RecyclerView = findViewById(R.id.list)
      fun setRecyclerViewScrollListener() {
          list_view.addOnScrollListener(object : RecyclerView.OnScrollListener() {
              override fun onScrolled(recyclerView: RecyclerView?, dx: Int, dy: Int) {
                  val height = list_view.getHeight()
  
                  val diff = height-dy
                  if (diff &lt; 1000){
                      /*load next list */
                  }
              }
          })
      }
      setRecyclerViewScrollListener()
  }
  </code></pre>
  
  <p>or this </p>
  
  <pre><code>val inflater = LayoutInflater.from(this@MainActivity)
  val layout = inflater.inflate(R.layout.append_list, null, false)
  button.setOnClickListener{screen.addView(layout)}
  </code></pre>
  
  <p>Is there a bullet proof method where you can simply append elemets like with html and js? I wrote this snippet in 2 min. Is there a similar "easy" way in Android/Kotlin? </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$("#next").click(function(){
    $(".append_text").append("new text &lt;img src='http://static.webshopapp.com/shops/015426/files/005031634/560x625x2/kek-amsterdam-wandtattoo-hase-forest-friends-braun.jpg'/&gt;")
  })</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;button id="next"&gt;Load&lt;/button&gt;
  
  &lt;span class="append_text"&gt; &lt;/span&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>In general I recive a lot of errors for choosing the wrong Layout. I tried Listview and contrainlayout and recycling Layout and Vertical Scrolling layout and so on. Is there a simple body tag where you can simply append a xml file?</p>
  
  <p>I think I go the wrong way the whole time because I see everything though the eyes of a Web. Dev. while android does not have the classical DOM. Can anybody explain it to me with an minimal example on how to append a xml file to the main xml file on button click/on scroll?</p>