Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think there is some misunderstanding here about how the <code>findViewById</code> works. I'll try to explain it below. Hope this helps, let me know if it doesn't.</p> <p>There are two possible <code>findViewById()</code> that can be used.</p> <ol> <li><p><a href="http://developer.android.com/reference/android/app/Activity.html#findViewById%28int%29" rel="nofollow"><code>Activity.findViewById()</code></a>: this can be used to find a view in the current activity's main content view -- that is, the view that was set using <a href="http://developer.android.com/reference/android/app/Activity.html#setContentView%28int%29" rel="nofollow"><code>setContentView()</code></a>. It cannot be used for any other purpose. For example, it cannot find a view from any other layout file -- the function simply would have no way of knowing how to find it. As far as I can tell, this is the function you're trying to use. If the last XML file you have is not the main layout, then the line <code>address2 = (LinearLayout)findViewById(R.id.sfsp2_layout)</code> will fail.</p></li> <li><p><a href="http://developer.android.com/reference/android/view/View.html#findViewById%28int%29" rel="nofollow"><code>View.findViewById()</code></a>: this function can be used to find a view that is contained in some other view. E.g. if you have <code>view1</code> that contains <code>view2</code>, and <code>view2</code> has ID <code>some_id</code>, then you can find <code>view2</code> by calling <code>view1.findViewById(R.id.some_id)</code>. In order for this to work, <code>view1</code> has to be fully initialized. E.g. if <code>view1</code>'s description is in XML, it has to be fully inflated first.</p></li> </ol> <p>In essence, if you want to work with a view that is described in a separate XML file, you have to inflate it first. I don't think there is a way around it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload