NotFound リソース例外に問題があります。リソース ID は設定したものとまったく同じであると確信していますが、とにかく失敗します! 「findViewById( R.id.editText1 )」を含む最初の行が適切に実行され、「start!」というラベルが表示されるので、これは興味深いことです。editText1 で、ただしスレッド内の 2 番目のものは次のように失敗します。
09-29 00:17:45.103: E/AndroidRuntime(347): android.content.res.Resources$NotFoundException: String resource ID #0x0
誰でもこの種の問題で私を助けることができますか? コードは次のとおりです。
EditText editText = ( EditText ) findViewById( R.id.editText1 );
editText.setText( "start!" );
final Handler handler = new Handler();
Runnable runnable = new Runnable() {
@Override
public void run() {
for (int i = 0; i <= 10; i++) {
final int value = i;
try {
Thread.sleep( 1000 );
} catch ( InterruptedException e ) {
e.printStackTrace();
}
handler.post( new Runnable() {
@Override
public void run() {
EditText editText = ( EditText ) findViewById( R.id.editText1 );
editText.setText( value );
}
} );
}
}
};
Thread thread = new Thread( runnable );
thread.start();