Android: findviewbyid: finding view by id when view is not on the same layout invoked by setContentView

前端 未结 5 2045
陌清茗
陌清茗 2020-12-08 04:02

I have an activity MyActivity that extends from MapActivity. In the .xml file containing the layout I can only include the MapView



        
5条回答
  •  春和景丽
    2020-12-08 04:40

    try:

    Activity parentActivity = this.getParent();
    if (parentActivity != null)
    {
        View landmarkEditNameView = (EditText) parentActivity.findViewById(R.id. landmark_name_dialog_edit);
    }
    

提交回复
热议问题