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;
}
}
Use String.valueOf
to show Integer in TextView,as:
counterText.setText(String.valueOf(new Ship().getCounter()));
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다