tags:

views:

1383

answers:

3

Hi all! I have and activity MyActivity that extends from MapActivity. In the .xml file containing the layout I can only include the MapView:

However I do neet to find another view that is located in another .xml file. Unfortunately, findViewById returns null. How can I get the view I am looking for?

Thanks a lot in advance!

A: 

It's impossible. You can only find and access views that are currently running. If you want to check the value of ex. TextView used in previus activity you must save the value is SharedPreferences, database, file or pass by Intent.

skyman
+2  A: 

Thanks for commenting, I understand what you mean but I didnt want to check old values. I just wanted to get a pointer to that view.

Looking at somebodies code I have just found a workaround, you can access the root of a layout using LayoutInflater.

The code is the following, where $this is an Activity:

final LayoutInflater factory = getLayoutInflater();

final View textEntryView = factory.inflate(R.layout.landmark_new_dialog, null);

landmarkEditNameView = (EditText) textEntryView.findViewById(R.id.landmark_name_dialog_edit);

Basically get the inflater for $this context, access the root view through inflate method and finally call findViewById on the root view of the layout.

Hope is usefull for someone! Bye

Santiago
A: 

thanks buddy that helped me a lot

kartheek