CustomFragmentActivity.java


Dosyayı İndir
package com.godoro.androidfragments;

import android.support.v4.app.*;
import android.os.Bundle;
import android.view.*;


public class CustomFragmentActivity extends FragmentActivity {

    private Fragment currentFragment;
    private CustomFragmentOne fragmentOne;
    private CustomFragmentTwo fragmentTwo;
    private CustomFragmentThree fragmentThree;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_custom_fragment);

        /*
        fragmentOne=(CustomFragmentOne)fragmentManager
                .findFragmentById(R.id.fragmentOne);
        */
        fragmentOne = new CustomFragmentOne();
        fragmentTwo = new CustomFragmentTwo();
        fragmentThree = new CustomFragmentThree();

        FragmentManager fragmentManager =  getSupportFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.add(R.id.mainFrame, fragmentOne);
        fragmentTransaction.commit();
        currentFragment=fragmentOne;
    }

    public void onNextFragmentClick(View view) {
        if(currentFragment==fragmentOne){
            currentFragment=fragmentTwo;
        }else if(currentFragment==fragmentTwo){
            currentFragment=fragmentThree;

        }else if(currentFragment==fragmentThree){
            currentFragment=fragmentOne;

        }

        FragmentManager fragmentManager =  getSupportFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        //fragmentTransaction.replace(R.id.fragmentOne, currentFragment);
        fragmentTransaction.replace(R.id.mainFrame, currentFragment);
        fragmentTransaction.commit();
    }
}

				
Dosyayı İndir

Bu Sayfayı Paylaş:




Bu Sayfayı Paylaş:

İletişim Bilgileri

Takip Et

Her Hakkı Saklıdır. Bu sitede yayınlanan tüm bilgi ve fikirlerin kullanımından fibiler.com sorumlu değildir. Bu sitede üretilmiş , derlenmiş içerikleri, fibiler.com'u kaynak göstermek koşuluyla kendi sitenizde kullanılabilirsiniz. Ancak telif hakkı olan içeriklerin hakları sahiplerine aittir