补充说明一下,我这个inputView是inflate出来的inputView = (KeyboardView)getLayoutInflater().inflate(R.layout.input, null),我要如何给这个inputView动态地添加控件(TextView)呢?

解决方案 »

  1.   

    用相对布局吧,你的KeyboardView inputView需要继承RelativeLayout;
    此时如果要动态添加TextView,可以用下面的语句:TextView textView = new TextView(this);
    textView.setId(1);
    textView.setText("test");
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
        -2, -2);
    params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, -1);//布局在底部
    inputView.addView(textView, params);
      

  2.   

    不行。。KeyboardView继承的是另外一个东西,不能继承其他的
      

  3.   

    有没有人了解android的InputMethodService?我想问一下要怎样才能给这个service新建一个view(keyboardview和candidateview以外的)?