Reputation: 4438
I have the following function: createEl(View view, ....)
I have to go to the same View function I'm using in the:
setContentView(R.layout.activity_main)
.
I tried with:
View view = (View) getLayoutInflater().Inflate (R.layout.activity_main, null);
But it does not work. How can I do?
Upvotes: 1
Views: 53
Reputation: 18112
Your code isn't working because you are using different instances of the layout. Inflate the view and use that in setContentView()
.
Try this
View view = getLayoutInflater().inflate (R.layout.activity_main, null);
setContentView(view);
Now you can use view
the way you want. It would be the same instance which is loaded in the activity.
Upvotes: 3