您好,我正在尝试获取一个由 SeekBar 提供的整数,该整数使用 .getprogress 进入一个 Integer,该整数将由首选项保存,并将转到我的应用程序另一端的 toast 代码,以使事情变得更容易这里我的代码已经。
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.SeekBar.OnSeekBarChangeListener;
import tk.mizzeeboy.freestorageconverter.R;
public class SettingsActivity extends Activity{
SeekBar cl;
TextView t;
String lolly , finlly;
int hehe;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.333);
cl = (SeekBar) findViewById(R.id.seekB3r1);
t = (TextView) findViewById(R.id.textV3w1);
cl.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser) {
// TODO Auto-generated method stub
t.setTextSize((cl.getProgress()) * getResources().getDisplayMetrics().density);
hehe = cl.getProgress();
finlly.valueOf(hehe);
SharedPreferences mypreferences = getSharedPreferences("myPrefs", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = mypreferences.edit();
editor.putString("TeamName", finlly);
editor.commit();
}
});
}
}
在我的其他活动中,我想打开并阅读它的代码
SharedPreferences mypreferences = getApplicationContext().getSharedPreferences("myPrefs", Context.MODE_PRIVATE);
String teamnamestring = mypreferences.getString("TeamName", "Please Enter :)");
Toast andEggs = Toast.makeText(BitActivity.this, teamnamestring , Toast.LENGTH_SHORT);
andEggs.show();
但我的问题是,我每次都收到请输入符号,它不会接收我的整数,有人可以帮忙吗?