在popupwindow中输入类com.lamudi.phonefield.PhoneInputLayout时出错

时间:2017-04-11 09:05:41

标签: android xml popupwindow

在我的Android应用程序中,我使用了编译(' com.lamudi.phonefield:phone-field:0.1.3@aar')库,它将完美地用于活动布局。问题是它不会在弹出窗口中打开我得到有关xml布局的错误。

enter image description here

XML布局

        <com.lamudi.phonefield.PhoneInputLayout
        android:id="@+id/phone_input_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

Java源代码

public class PopupActivity extends Activity {

private Context mContext;
private Activity mActivity;
private android.widget.PopupWindow mPopupWindow;
private LinearLayout mBirthdetail;

@RequiresApi(api = Build.VERSION_CODES.N)
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_popup);

    mContext = getApplicationContext();

    // Get the activity
    mActivity = PopupActivity.this;

    LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);

    // Inflate the custom layout/view
    View customView = inflater.inflate(R.layout.raw_birthdate, null);

    mBirthdetail = (LinearLayout) findViewById(R.id.birth_detail);

    mPopupWindow = new android.widget.PopupWindow(
            customView,
            ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT
    );
    // mPopupWindow.setContentView(findViewById(R.id.demo));

    mPopupWindow.setAnimationStyle(R.style.PopupAnimation);


    if (Build.VERSION.SDK_INT >= 21) {
        mPopupWindow.setElevation(5.0f);
    }

    mPopupWindow.setFocusable(true);
    mPopupWindow.update();
    mPopupWindow.setOutsideTouchable(false);

    final PhoneInputLayout phoneInputLayout = (PhoneInputLayout) customView.findViewById(R.id.phone_input_layout);

    phoneInputLayout.setHint(R.string.phone_hint);

    phoneInputLayout.setDefaultCountry("DE");

    String phoneNumber = phoneInputLayout.getPhoneNumber();


    new Handler().postDelayed(new Runnable() {

        public void run() {
            mPopupWindow.showAtLocation(mBirthdetail, Gravity.CENTER, 0, 0);
        }

    }, 100L);
}

@Override
protected void onStop() {
    super.onStop();
    mPopupWindow.dismiss();
}

}

0 个答案:

没有答案
相关问题