Using Fragment
is the best option to achieve what you want.
But if you don't want to do it, you can make your welcome.java
a normal file(not an activity) and return your layout as a view from that file.
Then you can directly add this returned view into your FrameLayout
.
EDIT
1) Remove the extends Activity
from your class.
2) Remove all @Override
from that class.
3) Change your onCreate
to this:-
Activity activity;
View v;
public View onCreate(Activity activity)//change the name if you want
{
this.activity = activity;
Typeface rt=Typeface.createFromAsset(getAssets(),"font/Carleton.ttf");
//super.onCreate(savedInstanceState);
//setContentView(R.layout.wallpaper);
LayoutInflator li = activity.getLauoutInflator();
v = li.inflate(R.layout.wallpaper, null);
.
.
.
return v;
}
4) Replace all findViewById
with v.findViewById
5) Replace all getResources()
with activity.getResources()
6) Then in your tab.java
add the onCreate
of welcome.java
in your FrameLayout
as
Welcome welcome = new Welcome();
frameLayout.addView(welcome.onCreate(this));