开发者

I am not getting addView() method for object of view i.e v in my code below?

开发者 https://www.devze.com 2023-04-05 09:57 出处:网络
I want to add button dynamically in开发者_JAVA百科 this view i.e. v public class MyviewActivity extends Activity {

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消