2011-08-30 39 views
2

我试图创建一个Android键盘,此代码的工作,当我试图让findViewById在InputMethodService中不起作用,我该怎么办?

LinearLayout LinLayBg = (LinearLayout)findViewById(R.id.LL_total); 

用按钮来填充它精细到目前为止

package keyboard.rob.com; 

import... 

public class xyz extends InputMethodService 
implements KeyboardView.OnKeyboardActionListener { 

    private LinearLayout mInputView; 

    @Override public View onCreateInputView() { 
     mInputView = (LinearLayout) getLayoutInflater().inflate(R.layout.main, null); 
     return mInputView; 
    } 

... 

但后来,它展示

“*的方法findViewById(INT)是未定义的类型ZYZ *”

任何想法?谢谢!

回答

6

我想你试图从视图的非实例调用方法findViewById(int id);

尝试:

mInputView.findViewById(R.id.LL_total); 

希望它有助于

+0

谢谢,成功了! :) – Roger

+0

很高兴听到它:) – Houcine

3

你应该能够做到这一点是这样的:

View.findViewById(R.id.LL_total);