TimePickerFragment不起作用 [英] TimePickerFragment Not Working

查看:98
本文介绍了TimePickerFragment不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据官方Android开发人员指南,用户单击此按钮,系统将调用以下方法:

According to the official Android Dev guide, when the user clicks this button, the system calls the following method:

public void showTimePickerDialog(View v) {
    DialogFragment newFragment = new TimePickerFragment();
    newFragment.show(getSupportFragmentManager(), "timePicker");
}

但是,当我在片段活动"中尝试此操作时,它会以红色显示TimePickerFragment.并提示TimePickerFragment()无法解析.

However, when I try this in my Fragment Activity, it shows TimePickerFragment in red. And prompts that TimePickerFragment() cannot be resolved.

这些是我与TimePicker相关的导入:

These are my imports related to TimePicker :

import android.app.AlarmManager;
import android.app.DatePickerDialog;
import android.app.DatePickerDialog.OnDateSetListener;
import android.app.Dialog;
import android.app.DialogFragment;
import android.support.v4.app.FragmentActivity;
import android.view.View.OnClickListener;
import android.widget.DatePicker;
import android.widget.TimePicker;
import android.app.TimePickerDialog;

当我尝试使用DatePicker时,DatePickerFragment起作用.

When I try this for DatePicker, the DatePickerFragment works.

推荐答案

您正在使用

You are using getSupportFragmentManager ,So

要做

import android.support.v4.app.DialogFragment;

不要

import android.app.DialogFragment;

这篇关于TimePickerFragment不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆