How to load class at runtime in android app?
In my android project I've two layouts in that first layout 开发者_运维知识库having one button if i click that button I need to display the second layout in the same layout for this I created a view by using LayoutInflater
and attached it to "Table Layout" which is present in first layout.
Everything should be fine but the corresponding class file for the second layout is not loading. Without loading I'm not able to call events like click and some other loader events so any one help me how can I load the corresponding class file when i click button in first layout?
It's difficult to understand what you mean by class not loading.
If you want some layout objects to be hidden at a particular time, look into the visibility
parameter in xml or setVisibility(true/false)
in code.
If you want to display a whole different screen, create a second activity and call it:
Intent i = new Intent(CallingActivity.this, ActivityToStart.class);
startActivity(i);
Your question is difficult to understand, but you appear to be trying to achieve an effect like embedding one activity inside another. You may want to look at the android developer docs about the "fragments" API, which is the currently-recommended way of achieving this kind of effect.
精彩评论