findViewById not working for an include?

后端 未结 7 1278
终归单人心
终归单人心 2020-11-27 06:05

I have an include like:


The include layout looks like (te

7条回答
  •  Happy的楠姐
    2020-11-27 06:29

    Try retrieving the and then searching within that

    Make sure your root has the same ID as the root element in the included XML file.. ex

    
    

    Then retrieve your "inner" content using:

    FrameLayout outer = (FrameLayout)findViewById(R.id.outer);
    
    ImageView iv = (ImageView)outer.findViewById(R.id.inner);
    if (iv == null) {
        Log.e(TAG, "Not found!");
    }
    

提交回复
热议问题