开发者

same menu different activities

开发者 https://www.devze.com 2023-02-07 20:20 出处:网络
I want to show the same menu (made with imageviews) on all my activies, and I try: public class BaseActivity extends Activity {

I want to show the same menu (made with imageviews) on all my activies, and I try:

public class BaseActivity extends Activity {

    ImageView iv1;
    ...

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    {
        super.onCreate(savedInstanceState);

        iv1 = (ImageView)findViewById(R.id.image1);
    }
开发者_StackOverflow
    ...
}

and the others activities looks like:

public class PlayersActivity extends BaseActivity {
    protected void onCreate (Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
    }
}

But, the activities don't see the ImageView that I defined on the BaseActivity.

I have a null object with the imageview.


iv1 will always be null, in the base activity or the subclass, because you never called setContentView

0

精彩评论

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