Android FragmentTransaction - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android FragmentTransaction class.

This code example shows how to use the following methods: addToBackStack, remove
            DialogFragmentHelper fragment, Bundle arguments, String tag) {
        FragmentManager manager = activity.getSupportFragmentManager();
        FragmentTransaction transaction = manager.beginTransaction();
        Fragment current = manager.findFragmentByTag(tag);
        if (current != null)
            transaction.remove(current);
        transaction.addToBackStack(null);
 
        fragment.setArguments(arguments);
        fragment.show(manager, tag);
    } 
 
    /** 
     * Create bundle with standard arguments 
     * 
     * @param title 
     * @param message 
     * @param requestCode 
     * @return bundle 
     */ 
Full Snippet Info
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: add, commit
	} 
 
	public static void startFragment(Fragment fragment) {
		FragmentManager fragmentManager = new FragmentActivity().getSupportFragmentManager();
		FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
		fragmentTransaction.add(fragment, null);
		fragmentTransaction.commit();
	} 
} 
Full Snippet Info
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
 
import static android.support.v4.app.Watson.OnCreateOptionsMenuListener; 
import static android.support.v4.app.Watson.OnOptionsItemSelectedListener; 
import static android.support.v4.app.Watson.OnPrepareOptionsMenuListener; 
 
public class SherlockFragment extends Fragment implements OnCreateOptionsMenuListener, OnPrepareOptionsMenuListener, OnOptionsItemSelectedListener {
    private SherlockFragmentActivity mActivity;
 
    public SherlockFragmentActivity getSherlockActivity() { 
        return mActivity;
    } 
 
    @Override 
    public void onAttach(Activity activity) {
        if (!(activity instanceof SherlockFragmentActivity)) {
            throw new IllegalStateException(getClass().getSimpleName() + " must be attached to a SherlockFragmentActivity.");
        } 
        mActivity = (SherlockFragmentActivity)activity;
 
        super.onAttach(activity);
Full Snippet Info
10
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: commit, remove
	 
	public static void dismissLoadingProgress(FragmentManager fragman) {
		FragmentTransaction tr = fragman.beginTransaction();
		Fragment frag = fragman.findFragmentByTag("loading");
		if(frag != null){
			tr.remove(frag);
		} 
		tr.commit();
	} 
 
} 
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: setRetainInstance
	 
	public ColorFragment() {  
		this(R.color.white);
	} 
	 
	public ColorFragment(int colorRes) {
		mColorRes = colorRes;
		setRetainInstance(true);
	} 
 
	@Override 
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		if (savedInstanceState != null)
			mColorRes = savedInstanceState.getInt("mColorRes");
		int color = getResources().getColor(mColorRes);
		// construct the RelativeLayout 
		RelativeLayout v = new RelativeLayout(getActivity());
		v.setBackgroundColor(color);		
		return v;
	} 
Full Snippet Info
10
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
package com.newsblur.fragment; 
 
import android.os.Bundle; 
import android.support.v4.app.Fragment; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.view.ViewGroup; 
 
import com.newsblur.R; 
 
public class LoadingFragment extends Fragment {
	 
	@Override 
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		return inflater.inflate(R.layout.fragment_loadingitems, null);
	} 
 
} 

10
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: commit, remove
This code example shows how to use the following methods: addToBackStack, commit, replace
        // Create the list fragment and add it as our sole content. 
        ReportStopProblemFragment content = new ReportStopProblemFragment();
        content.setArguments(args);
 
        FragmentTransaction ft = fm.beginTransaction();
        ft.replace(android.R.id.content, content);
        ft.addToBackStack(null);
        ft.commit();
    } 
 
    private Spinner mCodeView;
    private TextView mUserComment;
 
    @Override 
    protected int getLayoutId() { 
        return R.layout.report_stop_problem; 
    } 
 
    @Override 
    public void onViewCreated(View view, Bundle savedInstanceState) {
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License. 
 */ 
 
package com.actionbarsherlock.sample.fragments; 
 
import android.os.Bundle; 
import android.support.v4.app.Fragment; 
import android.support.v4.app.FragmentTransaction; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.view.View.OnClickListener; 
import android.view.ViewGroup; 
import android.widget.Button; 
import android.widget.TextView; 
import com.actionbarsherlock.app.SherlockFragment; 
import com.actionbarsherlock.app.SherlockFragmentActivity; 
Full Snippet Info
10
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: setRetainInstance
  public ContentFragment() { 
    this(null); 
  } 
   
  public ContentFragment(String url) {
    super(); 
     
    urlToLoad=url;
    setRetainInstance(true);
  } 
   
  @Override 
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                            Bundle savedInstanceState) {
    return(inflater.inflate(R.layout.content_fragment, container, false));
  } 
   
  @Override 
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
Full Snippet Info
10
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Android FragmentTransaction Questions & Answers:

See Code Examples for Android FragmentTransaction Methods: