我想在此 View 中动态添加按钮,即 v
public class MyviewActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LayoutInflater inflater=this.getLayoutInflater();
View v=inflater.inflate(R.layout.main, null, true);//view
}
}
最佳答案
View
类没有 addView
方法。您需要使用扩展 ViewGroup
的基类之一,例如 LinearLayout
。
关于android - 我没有在下面的代码中获取 View 对象的 addView() 方法,即 v?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7421422/