私のアプリは乱数を生成してTextView
に設定し、同時にカウントダウンタイマーからTextView
に1つのボタンをクリックして時間を設定する必要があります。しかし、私はそれを動作させる方法の解決策を見つけることができません。1つのボタンが2つのtextViewに応答する
public class GenerateToken extends ActionBarActivity {
TextView show;
CountDownT timer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_generate_token);
show =(TextView)findViewById(R.id.textView2);
show.setText("60");
}
public void generate (View v)
{
Random rand = new Random();
int number = rand.nextInt(1999999999 - 1000000000)+1000000000;
TextView myText = (TextView)findViewById(R.id.textView);
String myString = String.valueOf(number);
myText.setText(myString);
timer.start();
}
}
public class CountDownT extends CountDownTimer{
public CountDownT (long InMillisSeconds, long TimeGap){
super(InMillisSeconds,TimeGap);
}
@Override
public void onTick(long l){
show.setText((l/1000) +"");
}
@Override
public void onFinish(){
show.setText("Request New Token..");
}
}
ようこそ。あなたの質問はほぼ大丈夫ですが、私は何が間違っているのか理解するのに困っています。現在の行動は何ですか?それはあなたの期待される行動とどのように違いますか?また、あなたの投稿を編集して、そのコードの書式設定を修正することができればそれは素晴らしいでしょう。 – Michael