0
訪問另一個類中的對象時出現錯誤。以下是我的代碼:訪問變量時出錯
package FinalProj.com;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.os.CountDownTimer;
public class iFallApp extends Activity{
public Object textView1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//TextView textview = new TextView(this);
//textview.setText("This is the iFall tab");
// setContentView()
setContentView(R.layout.ifallapp);
View textView1 = findViewById(R.id.textView1);
MyCount counter = new MyCount(5000,1000);
counter.start();
}
public class MyCount extends CountDownTimer{
public MyCount(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
}
iFallApp app1 = new iFallApp();
@Override
public void onFinish() {
// TODO Auto-generated method stub
app1.textView1.setText("done");
}
@Override
public void onTick(long millisUntilFinished) {
// TODO Auto-generated method stub
}
}
}
我試圖訪問myFount類的iFallApp的textView1。然而,它不給我一個textView1的錯誤,但錯誤是方法「setText(字符串)」未定義類型的對象。
請建議。