samedi 28 novembre 2015

requestfeature() must be called before adding content error on onClick()

public class MyFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener {

private View mRootView;

private Item currentItem = null;

private Toolbar mToolbar;

private TextView dateText;

private TextView error;

private EditText item;

private EditText quantity;

private EditText note;

private Spinner sspinner;

private Spinner spinner;

private int spinnerCount=0;

private int spinnerInitializedCount=0;

private int remSpinnerCount=0;

private int remSpinnerInitializedCount=0;

public MyFragment() {

}

public static MyFragment newInstance(long id) {

    MyFragment myFragment = new MyFragment();

    if (id > 0) {

        Bundle bundle = new Bundle();

        bundle.putLong("id", id);

        myFragment.setArguments(bundle);

    }

    return myFragment;

}

public void getCurrentItem() {

    Bundle args = getArguments();

    if (args != null && args.containsKey("id")) {

        long id = args.getLong("id", 0);

        if (id > 0) {

            currentItem = ItemManager.newInstance(getActivity()).getMyItem(id);

        }

    }

}

@Override

public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setHasOptionsMenu(true);

    getCurrentItem();

}

@Override

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    mRootView = inflater.inflate(R.layout.item_fragment, container, false);

    item=(EditText)mRootView.findViewById((R.id.item));

    quantity=(EditText)mRootView.findViewById(R.id.amount);

    error = (TextView)mRootView.findViewById(R.id.error);

    note = (EditText)mRootView.findViewById(R.id.notes);

    dateText = (TextView)mRootView.findViewById(R.id.date_selected);

    spinner = (Spinner) mRootView.findViewById(R.id.units);

    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.units, android.R.layout.simple_spinner_dropdown_item);

adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    spinner.setAdapter(adapter);

    sspinner = (Spinner) mRootView.findViewById(R.id.reminder_list);

    ArrayAdapter<CharSequence> aadapter = ArrayAdapter.createFromResource(getActivity(), R.array.countdown_reminder, android.R.layout.simple_spinner_dropdown_item);

    aadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    sspinner.setAdapter(aadapter);

    spinner.setOnItemSelectedListener(spinnerListener);

    sspinner.setOnItemSelectedListener(spinnerListener);

    spinnerCount=1;

    sspinnerCount=1;

    return mRootView;

}

public static final String[] months = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};

@Override

public Dialog onCreateDialog(Bundle savedInstanceState){
    int year = calendar.get(Calendar.YEAR);
    int month = calendar.get(Calendar.MONTH);
    int date = calendar.get(Calendar.DATE);

    return new DatePickerDialog(getActivity(), this, year, month, date);

}

@Override

public void onDateSet(DatePicker view, int year, int month, int date) {

    calendar.set(year, month + 1, date);

    calendar.getTime();

    String mon = months[month];

    //get the selected date

    selected_date = ""+view.getDayOfMonth()+ "/" + ""+((view.getMonth())+1)+ "/" + "" +view.getYear();

    //Display the selected date after the date has been set

    dateText = (TextView)getActivity().findViewById(R.id.date_selected);

    dateText.setText(selected_date);

}

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



requestfeature() must be called before adding content error on onClick()

Aucun commentaire:

Enregistrer un commentaire