Search in sources :

Example 1 with Fragment

use of android.support.v4.app.Fragment in project android-betterpickers by code-troopers.

the class TimePickerDialogFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.time_picker_dialog, container, false);
    Button doneButton = (Button) view.findViewById(R.id.done_button);
    Button cancelButton = (Button) view.findViewById(R.id.cancel_button);
    cancelButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            dismiss();
        }
    });
    cancelButton.setTextColor(mTextColor);
    doneButton.setTextColor(mTextColor);
    doneButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            for (TimePickerDialogHandler handler : mTimePickerDialogHandlers) {
                handler.onDialogTimeSet(mReference, mPicker.getHours(), mPicker.getMinutes());
            }
            final Activity activity = getActivity();
            final Fragment fragment = getTargetFragment();
            if (activity instanceof TimePickerDialogHandler) {
                final TimePickerDialogHandler act = (TimePickerDialogHandler) activity;
                act.onDialogTimeSet(mReference, mPicker.getHours(), mPicker.getMinutes());
            } else if (fragment instanceof TimePickerDialogHandler) {
                final TimePickerDialogHandler frag = (TimePickerDialogHandler) fragment;
                frag.onDialogTimeSet(mReference, mPicker.getHours(), mPicker.getMinutes());
            }
            dismiss();
        }
    });
    mPicker = (TimePicker) view.findViewById(R.id.time_picker);
    mPicker.setSetButton(doneButton);
    mPicker.setTheme(mTheme);
    getDialog().getWindow().setBackgroundDrawableResource(mDialogBackgroundResId);
    return view;
}
Also used : Button(android.widget.Button) Activity(android.app.Activity) View(android.view.View) Fragment(android.support.v4.app.Fragment) DialogFragment(android.support.v4.app.DialogFragment)

Example 2 with Fragment

use of android.support.v4.app.Fragment in project android-betterpickers by code-troopers.

the class SampleHmsUsingFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.frame_layout);
    Fragment fragment = new SampleHmsFragment();
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.replace(R.id.frame, fragment);
    transaction.commit();
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) SampleHmsFragment(com.codetroopers.betterpickers.sample.fragment.SampleHmsFragment) Fragment(android.support.v4.app.Fragment) SampleHmsFragment(com.codetroopers.betterpickers.sample.fragment.SampleHmsFragment)

Example 3 with Fragment

use of android.support.v4.app.Fragment in project android-betterpickers by code-troopers.

the class TimePickerBuilder method show.

/**
     * Instantiate and show the Picker
     */
public void show() {
    if (manager == null || styleResId == null) {
        Log.e("TimePickerBuilder", "setFragmentManager() and setStyleResId() must be called.");
        return;
    }
    FragmentTransaction ft = manager.beginTransaction();
    final Fragment prev = manager.findFragmentByTag("time_dialog");
    if (prev != null) {
        ft.remove(prev).commit();
        ft = manager.beginTransaction();
    }
    ft.addToBackStack(null);
    final TimePickerDialogFragment fragment = TimePickerDialogFragment.newInstance(mReference, styleResId);
    if (targetFragment != null) {
        fragment.setTargetFragment(targetFragment, 0);
    }
    fragment.setTimePickerDialogHandlers(mTimePickerDialogHandlers);
    fragment.setOnDismissListener(mOnDismissListener);
    fragment.show(ft, "time_dialog");
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) Fragment(android.support.v4.app.Fragment)

Example 4 with Fragment

use of android.support.v4.app.Fragment in project android-betterpickers by code-troopers.

the class SampleDateUsingFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.frame_layout);
    Fragment fragment = new SampleDateFragment();
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.replace(R.id.frame, fragment);
    transaction.commit();
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) SampleDateFragment(com.codetroopers.betterpickers.sample.fragment.SampleDateFragment) SampleDateFragment(com.codetroopers.betterpickers.sample.fragment.SampleDateFragment) Fragment(android.support.v4.app.Fragment)

Example 5 with Fragment

use of android.support.v4.app.Fragment in project TakePhoto by crazycodeboy.

the class SimpleFragmentActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.simple_fragment_layout);
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.add(R.id.fragment1, fragment = new SimpleFragment(), "test");
    transaction.commit();
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction)

Aggregations

Fragment (android.support.v4.app.Fragment)617 FragmentTransaction (android.support.v4.app.FragmentTransaction)220 Bundle (android.os.Bundle)140 View (android.view.View)129 FragmentManager (android.support.v4.app.FragmentManager)115 DialogFragment (android.support.v4.app.DialogFragment)77 TextView (android.widget.TextView)55 FragmentInstruction (de.madcyph3r.example.example.FragmentInstruction)48 MaterialMenu (de.madcyph3r.materialnavigationdrawer.menu.MaterialMenu)48 MaterialItemSectionFragment (de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment)48 FragmentDummy (de.madcyph3r.example.example.FragmentDummy)43 Intent (android.content.Intent)39 ViewPager (android.support.v4.view.ViewPager)35 FragmentActivity (android.support.v4.app.FragmentActivity)34 BaseFragment (com.waz.zclient.pages.BaseFragment)29 ImageView (android.widget.ImageView)27 FragmentPagerAdapter (android.support.v4.app.FragmentPagerAdapter)25 Button (android.widget.Button)24 ArrayList (java.util.ArrayList)24 FragmentStatePagerAdapter (android.support.v4.app.FragmentStatePagerAdapter)21