2017-08-03 107 views
0

@覆蓋公共查看onCreateInputView(){如何更改自定義鍵盤主題android系統

//Start SharedPreferences Fetch 
    SharedPreferences pref1=getSharedPreferences("test",1); 
    int theme=pref1.getInt("theme1",1); 

    int theme_1=pref1.getInt("theme2",2); 

    if(theme==1) 
    { 
     this.mInputView= (LatinKeyboardView) this.getLayoutInflater().inflate(R.layout.input2,null); 
    } 
    else if(theme_1==1) 
    { 
     this.mInputView= (LatinKeyboardView) this.getLayoutInflater().inflate(R.layout.input,null); 
    } 
    //End SharedPreferences Fetch 

// mInputView =(LatinKeyboardView)getLayoutInflater()。膨脹( // R.layout.input,空);

this.mInputView.setOnKeyboardActionListener(this); 
// mInputView.setPreviewEnabled(false); 
    this.mInputView.setKeyboard(mQwertyKeyboard); 
    return this.mInputView; 
} 

回答

0

我不完全確定你要做什麼,但ContextThemeWrapper可能是你在找什麼。您可以創建ContextThemeWrapper,而不是根據當前上下文進行膨脹,然後使用它膨脹您的XML。

Context themedContext = new ContextThemeWrapper(context,themeId); 
LayoutInflator.from(themedContext).inflate(...)