私はAndroidの初心者です。AndroidアプリのメインActivity
クラスには、TextView
他のクラスからのさまざまなステータスメッセージを表示するためのが含まれています。他のクラスのステータス値TextView
でmainを更新したい。Activity
メインアクティビティクラスと他のクラスの間に直接の接続はありません。アンドロイドで可能ですか?はいの場合、私はそれをすることに気づいていません。親切にそれを行うための解決策を提供してください
コードスニペット
//main activity
public class MainMenu extends Activity {
static String status = "Hello Friends";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView tv = (TextView)findViewById(R.id.mytext);
tv.setText(status);
MyOtherClass myclass = new MyOtherClass();
myclass.connect();
}
他のクラスはアクティビティクラスではありません
// Other class
public class MyOtherClass {
public MyOtherClass(){
}
public void connect(){
String strIP = Mtx.confRead("IPAddress");
String strPort = Mtx.confRead("Port");
String msg = "Connecting...";
// i want to show value of msg varible in Textview of main activity from here
}
ありがとうございます