죄송합니다. 이것은이 프로젝트에 대해서 제가 물어보아야 만했던 세 번째 질문과 같아야합니다. = (안드로이드 환경 설정은 어떻게 작동합니까?
는 내가 뭘 할 수 있기를 원하는 것은이 내 코드에 오류 모두 활동이 좋은이 실행되지 않습니다. 환경 활동에 체크 상자를 사용하여 라디오 버튼의 가시성을 전환
이지만, 체크 상자를 선택하거나 선택하지 않은 경우 가시성에 변화가 없다. 여기
이 라디오 버튼 여기import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.widget.EditText;
import android.widget.RadioButton;
import com.medialets.android.analytics.MMAnalyticsManager;
public class Temperature extends Activity {
MMAnalyticsManager mManager;
private EditText text;
public void onStart(Bundle savedInstanceState){
super.onStart();
getPrefs();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.temperature);
text = (EditText)findViewById(R.id.EditText01);
mManager = MMAnalyticsManager.sharedInstance(this);
mManager.start("codeHere", "1.0",
false);
}
@Override
public void onPause() {
super.onPause();
mManager.pause();
}
@Override
public void onResume() {
super.onResume();
mManager.resume();
}
@Override
public void onDestroy() {
super.onDestroy();
mManager.stop();
}
public void myClickHandler(View view){
switch (view.getId()) {
case R.id.Button01:
RadioButton celsiustokelvinButton = (RadioButton) findViewById (R.id.RadioButton05);
RadioButton celsiustofarenheitButton = (RadioButton) findViewById(R.id.RadioButton01);
RadioButton farenheittocelsiusButton = (RadioButton) findViewById(R.id.RadioButton02);
RadioButton farenheittokelvinButton = (RadioButton) findViewById(R.id.RadioButton06);
RadioButton kelvintocelsiusButton = (RadioButton) findViewById (R.id.RadioButton03);
RadioButton kelvintofarenheitButton=(RadioButton) findViewById (R.id.RadioButton04);
float inputValue = Float.parseFloat(text.getText().toString());
if (celsiustofarenheitButton.isChecked()) {
text.setText(String
.valueOf(convertCelsiusToFarenheit(inputValue)));
} if (farenheittocelsiusButton.isChecked()) {
text.setText(String
.valueOf(convertFarenheitToCelsius(inputValue)));
} if (celsiustokelvinButton.isChecked()) {
text.setText(String
.valueOf(convertCelsiusToKelvin(inputValue)));
} if (farenheittokelvinButton.isChecked()) {
text.setText(String
.valueOf(convertFarenheitToKelvin(inputValue)));
} if (kelvintocelsiusButton.isChecked()) {
text.setText(String
.valueOf(convertKelvinToCelsius(inputValue)));
} if (kelvintofarenheitButton.isChecked()) {
text.setText(String
.valueOf(convertKelvinToFarenheit(inputValue)));
}
break;
}}
private float convertFarenheitToCelsius(float fahrenheit){
return ((fahrenheit - 32) * 5/9);
}
private float convertCelsiusToFarenheit(float celsius){
return ((celsius * 9)/5) + 32;
}
private double convertCelsiusToKelvin(float celsius){
return celsius + 273.15;
}
private double convertFarenheitToKelvin(float farenheit){
return ((farenheit-32)/(1.8));
}
private double convertKelvinToCelsius(float kelvin){
return kelvin-273.1;
}
private double convertKelvinToFarenheit(float kelvin){
return kelvin*1.8-459.67;
}
boolean CheckboxPreference;
private void getPrefs() {
// Get the xml/preferences.xml preferences
SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(getBaseContext());
CheckboxPreference = prefs.getBoolean("checkboxPref", true);
}
}
및 내 활동은 활동 내 환경 설정
입니다import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.Preference.OnPreferenceClickListener;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.RadioButton;
import android.widget.Toast;
import android.widget.CompoundButton.OnCheckedChangeListener;
public class Preferences extends PreferenceActivity {
private RadioButton btn01;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
btn01 = (RadioButton)findViewById(R.id.RadioButton01);
Preference customPref = (Preference) findPreference("customPref");
customPref.setOnPreferenceClickListener(new OnPreferenceClickListener(){
public boolean onPreferenceClick(Preference preference) {
Toast.makeText(getBaseContext(),"The Custom Preference Has Been Clicked",Toast.LENGTH_LONG).show();
SharedPreferences customSharedPreference = getSharedPreferences("myCutomSharedPrefs", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = customSharedPreference.edit();
editor.putString("myCustomPref","The preference has been clicked");
editor.commit();
CheckBox();
return true;
}
private void CheckBox() {
final CheckBox ThisCheckBox = (CheckBox) findViewById (R.id.checkboxPref);
ThisCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener(){
@Override
public void onCheckedChanged(CompoundButton compoundButton,boolean test) {
if (ThisCheckBox.isChecked()){
btn01.setVisibility(View.VISIBLE);
} else {
btn01.setVisibility(View.GONE);
}
}
});
};
});
}}
죄송 같은 이유 단지 작동하지 않는
(그냥 보조 노트에 관해서는 어떤 생각을 가지고
누구의 분석 플러그가있을뿐만 아니라 다른 물건이있다. 의 로그 캣을보고 클릭 할 때 체크 박스가 어떤 결과를) 반환
편집 : 제안하지만 난 환경 설정은 여전히 아무 영향을주지 않는 것이 두려워으로 난 그냥 내 코드를 ammended 한 OK. 누구든지 어떤 아이디어가 있습니까 ?? = (
말하기, 당신이 말할 때, "는 로그 캣을보고 클릭 할 때 체크 박스가 어떤 결과를 반환)" , 나는 당신이 이클립스에서 그것을보고 있다고 가정합니다. 당신은 필요 없어. 필자는 "adb logcat -v time"을 사용하여 무엇이 진행되고 있는지를 훨씬 더 자세히 볼 수 있으며, 파일을 필터링하거나 저장하고 관련이있을 수있는 모든 것을 볼 수 있도록 Emacs에서 보는 것이 더 좋습니다. 좀 더 유익한 logcat 출력을 얻으려고 시도해 볼 수도 있습니다. BTW : Log.d(), Log.w() 등의 함수 호출이 위에 나와있는 코드에 뿌려져 더 이상 작동하지 않는 이유를 알아 내야합니다. –