2017-08-03 63 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(...) 
相关问题