[英]I am not getting addView() method for object of view i.e v in my code below?
I want to add button dynamically in this view ie v 我想在此视图中动态添加按钮,即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
}
}
The View
class doesn't have an addView
method. View
类没有addView
方法。 You need to use one of the base classes that extends ViewGroup
such as LinearLayout
. 您需要使用扩展ViewGroup
的基类之一,例如LinearLayout
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.