2014年10月23日 星期四

[程式] Android - View / Window

  • 使用 WindowManager 產生 / 關閉 float view
  • WindowManager wManager = getApplicationContext()
                             .getSystemService(Context. WINDOW_ SERVICE);
    LayoutInflater mInflater = LayoutInflater.from(this);
    mFloatView = mInflater.inflate(R.id.xxx, null);
    
    // show view
    mWindowManager.addView(mFloatView, mParams);
    
    // close view
    mWindowManager.removeView(mFloatView);
    REF:
    http://www.embedu.org/Column/Column522.htm
    http://www.eoeandroid.com/thread-211504-1-1.html

  • [ E ]
    (Pass compiling / App crashes on run time & get logcat error)
    android.view.InflateException: Binary XML file line #14: Error inflating class <package name>.<class name>[ S ]
    1.
    Check the package/class name in the xml and java file. They should be the same.
    In xml:
    The tag name should be <package name>.<class name>
    In java:
    The package at the 1st line should be "package <package name>;"
    The class name declared in "public class XXX extend ... " should be <class name>
    2.
    There should be constructors for more than one parameters.
    ie. For class "ClassName", there should be the following constructors.
    public ClassName(Context context) {
        super(context);
    }
    public ClassName(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
    public ClassName(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }
    REF:
    http://blog.csdn.net/huangxiaohu_coder/article/details/8497286
    http://stackoverflow.com/questions/3739661/android-error-inflating-class

  • [ E ]
    (Pass compiling / App crashes on run time & get logcat error)
    Unable to add window android.view.ViewRootImpl$W@22075458 -- permission denied for this window type
    [ S ]
    Add <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW">
    in AndroidManifest.xml
    REF:
    http://stackoverflow.com/questions/7569937/unable-to-add-window-android-view-viewrootw44da9bc0-permission-denied-for-t

沒有留言:

張貼留言