I am not getting addView() method for object of view i.e v in my code below?
I want to add button dynamically in开发者_JAVA百科 this view i.e. 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. You need to use one of the base classes that extends ViewGroup
such as LinearLayout
.
精彩评论