复制粘贴选项弹出窗口没有出现

时间:2013-12-30 13:42:25

标签: android service window-managers

我正在扩展Service类来执行我的任务并扩展布局。但是,长按EditText后,布局中的EditText没有显示复制粘贴弹出窗口。

这是我的代码。

public class FormService extends Service {

    WindowManager windowManager;
    LayoutInflater inflater;
    ImageButton btn_close;
    EditText name;
    View formView;

    boolean flag = true;

    @Override
    public IBinder onBind(Intent intent) {
        // Not used
        return null;
    }

    @Override
    public void onCreate() {
        super.onCreate();

        inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);

        @SuppressWarnings("deprecation")
        WindowManager.LayoutParams paramsForm = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.FILL_PARENT,
                WindowManager.LayoutParams.FILL_PARENT,
                WindowManager.LayoutParams.TYPE_PHONE,
                WindowManager.LayoutParams.FLAG_FULLSCREEN,
                PixelFormat.TRANSLUCENT);

        formView = inflater.inflate(R.layout.colorpopup, null);

        name = (EditText) formView.findViewById(R.id.name);

        btn_close = (ImageButton) formView.findViewById(R.id.btn_close);
        ButtonEffect.buttonEffect(btn_close);
        btn_close.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View formView) {
                stopSelf();
            }
        });

        windowManager.addView(formView, paramsForm);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (formView != null)
            windowManager.removeView(formView);
    }
}

请帮忙。 感谢。

0 个答案:

没有答案