私はJavaとAndroidの開発に不慣れで、エラーを修正できません。変数を使用してaのテキストを変更したいTextView
のですが、ビュークラスは静的です。コードは次のとおりです。
public static class FirstTab extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.first_tab, null);
new Thread() {
public void run() {
MCQuery mcQuery = new MCQuery(serverAddress, 25565);
QueryResponse response = mcQuery.basicStat();
int Onlineplayers = response.getOnlinePlayers();
Log.d("MCQuery", "" + Onlineplayers + " Online Players");
}
}.start();
TextView onlinePlayersView = (TextView) findViewById(R.id.online_players);
onlinePlayersView.setText(Onlineplayers);
return v;
}
}
findViewById(int)
エラーは次のとおりです。「タイプActivityから非静的メソッドへの静的参照を作成できません」
どうすればこの問題を解決できますか?