开发者

How to access the variables that are in void onCreate class from another class (both are under activity subclass)?

I am trying to access some of the onCreate class variables from another class that is under activity class, for example

..Acivity class(..)
        Class onCreate(..){
              Final int intItemNo = 0;

        } 

        Class testing(){
             //some commands here, will need ac开发者_如何学JAVAcess to the intItemNo above.
        } 
 };


Place the variable definition outside of the onCreate Class. I am assuming this code is from an activity class so onCreate is really a method not a class. It does not change the answer though. If it is not, onCreate is not a good name for class as it conflicts with an android method.

public class1 extends Activity {

    Final int intItemNo;

    public void  onCreate(..){
         intItemNo = 0;
    } 

    Class testing(){
         intItemNo = 1;
    } 
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜