Question

I have one layout called sample.xml `

<FrameLayout
    android:id="@+id/actionbar"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
</FrameLayout>

`

i have two class one is tab.java second is wallpaper.java

so can any one suggest me how can i show wallpaper.java in frame-layout

Was it helpful?

Solution

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));

OTHER TIPS

I am not getting what you want to achieve.. But If you want to use layout something like tabs, you can achieve it using ViewPager or TabHost

EDIT

This might help you to achieve your requirement.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top