我有一个搜索栏,我想在按下按钮时消失,倒计时后重新出现。我在倒计时后使用seekBarTimeToPlay.setVisibility(view.INVISIBLE);的方法。onFinish()但是,我收到错误“无法解析符号'视图'”。而且“无法解析符号'seekBarTimeToPlay'。” 但似乎通过SeekBar seekBarTimeToPlay = (SeekBar) findViewById(R.id.seekBarTimeToPlay);在方法中添加另一个来解决这个问题。 //change timeToPlay seekBar SeekBar seekBarTimeToPlay = (SeekBar) findViewById(R.id.seekBarTimeToPlay); //set progress/thumb pos to right place seekBarTimeToPlay.setProgress(timeToPlay); seekBarTimeToPlay.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { timeToPlay = progress; updateTimeToPlay(timeToPlay, false); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { updateTimeToPlay(timeToPlay, true); } }); //start playing, countdown final Button buttonMain = (Button) findViewById(R.id.buttonMain); buttonMain.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { //countdown, updating time to tidy text view, progress bar or clock animation SeekBar seekBarTimeToPlay = (SeekBar) findViewById(R.id.seekBarTimeToPlay); if (phase == "none") { //parent presses button, child starts playing phase = "playing"; buttonMainText = "Pack Away Now"; //hide seekBar, doesn't change layout seekBarTimeToPlay.setVisibility(View.INVISIBLE); startCountDown(timeToPlay); } } });}如何从另一种方法更改可见性?我也不能使用static我不明白的。
1 回答
胡说叔叔
TA贡献1804条经验 获得超8个赞
视图应该从大写开始,因为它是类名:
seekBarTimeToPlay.setVisibility(View.GONE);
或者
seekBarTimeToPlay.setVisibility(View.VISIBLE);
并记住导入:
import android.view.View;
添加回答
举报
0/150
提交
取消