小编Ber*_*nas的帖子

弹出窗口中的微调器出错,单击时崩溃

我有一个从片段调用的PopupWindow,除了我的Spinner,一切都有效.当我点击我的Spinner时它会崩溃并给出错误:

"android.view.WindowManager $ BadTokenException:无法添加窗口 - 令牌android.view.ViewRootImpl$W@421a46d8无效;您的活动是否在运行?"

我的代码调用片段中的弹出窗口:

ManagerPopUp mManagerPopUp = new ManagerPopUp(getActivity());
mManagerPopUp.showPopUpAddEvent();
Run Code Online (Sandbox Code Playgroud)

我在ManagerPopUp中的代码显示Popup:

public class ManagerPopUp {

    private static final String TAG = "PopUpManager";
    private Context mContext;

    public ManagerPopUp(Context mContext){
        this.mContext = mContext;
    }

    public PopupWindow showPopUpAddEvent(){
            final PopupWindow popUp = new PopupWindow(mContext);

            LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View layout = inflater.inflate(R.layout.popup_add_event, null);

            //Code for popup event
            TextView txtRoom, txtTitle, txtEnd, txtStart;
            ToggleButton tgRepeateWeekly, tgAddReminder;
            Button btConfirme, btCancel;

            txtTitle = (TextView)layout.findViewById(R.id.txt_lesson_title_event);
            txtRoom = (TextView)layout.findViewById(R.id.txt_lesson_room_event);
            txtStart = (TextView)layout.findViewById(R.id.txt_lesson_start_hour_event);
            txtEnd = (TextView)layout.findViewById(R.id.txt_lesson_end_hour_event); …
Run Code Online (Sandbox Code Playgroud)

android android-adapter android-fragments android-spinner android-popupwindow

6
推荐指数
1
解决办法
2541
查看次数

EditText 的 Android 自动完成背景颜色

我注意到一些 Android 手机具有用于插入登录凭据的自动完成/自动插入功能。见图片:

在此处输入图片说明

我的问题是,我可以将此黄色背景颜色更改为另一种颜色吗?

android autocomplete android-layout android-edittext

4
推荐指数
1
解决办法
1829
查看次数