How to use global class variables in android

后端 未结 4 923
粉色の甜心
粉色の甜心 2021-01-26 09:12

Hi I am doing one app here. I\'m using global class varibles. It\'s working well, but if I\'m using more globalclass variables I\'m getting memory exceptions some times.

4条回答
  •  盖世英雄少女心
    2021-01-26 09:48

    You can also use Global Variable Activity class wise. As for example

     public class SecondClass extends Activity {
    String S1,S2,S3;
    EditText edt1,Edt2,Edt3;
    Button btn1,btn2,btn3;
    //like this wat Declare all variable you want to use in your Present Activity Class
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         setContentView(R.layout.second);
    edt1= (EditText)findViewById(R.id.tv);
    }
    }
    

提交回复
热议问题