How do i set the text of a TextView to a value of an integer from another class

XetronProgrammer

How do i set the text of a TextView to a value of an integer from another class.

the main activity where i want the text set below

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my);


   TextView counterText = (TextView) findViewById(R.id.counter);


   counterText.setText();


}

the class below

public class Ship implements Serializable {

        private static int counter = 0;
        public int getCounter()
        {
            return counter;
        }

    }
ρяσѕρєя K

Use String.valueOf to show Integer in TextView,as:

counterText.setText(String.valueOf(new Ship().getCounter()));

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

how to set a text of a textview from another activity

분류에서Dev

How do I set the value of my field so that I can call it from another class?

분류에서Dev

How to set text for JTextField from another class using DocumentFIlter?

분류에서Dev

How do I use a HashMap from another class or function?

분류에서Dev

How do you make string from textbox.text give an integer value, when using an array?

분류에서Dev

How do i open a class from within another class by selecting an item on ToolBar?? Python/PyQt

분류에서Dev

How do I return the result of a class-based view from another class-based view in Django?

분류에서Dev

How do I reference a string in another class?

분류에서Dev

How do I set combobox text

분류에서Dev

How do I can change contents of some div sections while clicking text from another div

분류에서Dev

How do I create an array using the order and value from one and the key of another?

분류에서Dev

How do i get id of autocomplete textview out of two autocomplete textview on item selected from its list?

분류에서Dev

How do I get the full value(including any additional tags) from .text of an XML key / Value using Javascript

분류에서Dev

How to get a TextView from other class

분류에서Dev

How to do autoincrement based on last value from another table?

분류에서Dev

On android, when I set the Text of a TextView dynamically it doesn't change

분류에서Dev

How do I set a default value on a semantic ui react dropdown

분류에서Dev

How do i copy files from one directory to another directory?

분류에서Dev

How do I return an object from another model in a scope?

분류에서Dev

How do I download a Debian ARM package from another computer

분류에서Dev

How can I do an array of object of my class (with inheritance of another custom class)?

분류에서Dev

how to set the text and image in particular item textview and imageview in horizontal listview

분류에서Dev

How do I produce a tab separated file from a text file?

분류에서Dev

How do I swap images and text in a seperate div from the mouseover?

분류에서Dev

How do I return a first class module from the same module?

분류에서Dev

How to set value for a base class from derived class in c# wpf

분류에서Dev

How to access variable from another class directly(i.e. without using class name or object)?

분류에서Dev

How do I find the index of an integer array?

분류에서Dev

How do I convert an integer to string in CakePHP?

Related 관련 기사

  1. 1

    how to set a text of a textview from another activity

  2. 2

    How do I set the value of my field so that I can call it from another class?

  3. 3

    How to set text for JTextField from another class using DocumentFIlter?

  4. 4

    How do I use a HashMap from another class or function?

  5. 5

    How do you make string from textbox.text give an integer value, when using an array?

  6. 6

    How do i open a class from within another class by selecting an item on ToolBar?? Python/PyQt

  7. 7

    How do I return the result of a class-based view from another class-based view in Django?

  8. 8

    How do I reference a string in another class?

  9. 9

    How do I set combobox text

  10. 10

    How do I can change contents of some div sections while clicking text from another div

  11. 11

    How do I create an array using the order and value from one and the key of another?

  12. 12

    How do i get id of autocomplete textview out of two autocomplete textview on item selected from its list?

  13. 13

    How do I get the full value(including any additional tags) from .text of an XML key / Value using Javascript

  14. 14

    How to get a TextView from other class

  15. 15

    How to do autoincrement based on last value from another table?

  16. 16

    On android, when I set the Text of a TextView dynamically it doesn't change

  17. 17

    How do I set a default value on a semantic ui react dropdown

  18. 18

    How do i copy files from one directory to another directory?

  19. 19

    How do I return an object from another model in a scope?

  20. 20

    How do I download a Debian ARM package from another computer

  21. 21

    How can I do an array of object of my class (with inheritance of another custom class)?

  22. 22

    how to set the text and image in particular item textview and imageview in horizontal listview

  23. 23

    How do I produce a tab separated file from a text file?

  24. 24

    How do I swap images and text in a seperate div from the mouseover?

  25. 25

    How do I return a first class module from the same module?

  26. 26

    How to set value for a base class from derived class in c# wpf

  27. 27

    How to access variable from another class directly(i.e. without using class name or object)?

  28. 28

    How do I find the index of an integer array?

  29. 29

    How do I convert an integer to string in CakePHP?

뜨겁다태그

보관