0
我的Android SeekBar出現問題,我在沿着酒吧的每個位置按一下,酒吧就會移動到此位置,但它不會刪除舊位置,因此我會產生奇怪的重影效果在圖像中看到。Android SeekBar舊進度未刪除
有沒有人見過這個?或知道它可能是什麼?
我的佈局文件如下
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/opt_back_button"
android:text="@string/opt_back_button_text"/>
<SeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/opt_test_seek_bar"
android:layout_margin="10dp"
android:max="100"
android:progress="0"
android:secondaryProgress="0"/>
</LinearLayout>
,我的主要的Java文件是
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.SeekBar;
import android.widget.Toast;
public class OptionsMenuActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// set the content view to the options menu
setContentView(R.layout.options_menu);
// get string from intent that started this activity
Intent source_intent = getIntent();
String message = source_intent.getStringExtra("games.longrun.toroidtussle.MESSAGE");
// display the message as a toast
Toast test_toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT);
test_toast.show();
// initialise the listeners for this activity
initialise_listeners();
}
private void initialise_listeners()
{
// get reference to the seekbar
SeekBar test_bar = (SeekBar)findViewById(R.id.opt_test_seek_bar);
// set listener for seek bar events
test_bar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
int progress = seekBar.getProgress();
Toast.makeText(OptionsMenuActivity.this, "Progress = " + progress, Toast.LENGTH_SHORT).show();
}
});
}
}
請發表您的代碼編輯 –
我的職務。 – SlyRaccoon