2012-06-03 2 views
2

나는 ArrayAdapter를 가지고 있으며, 뭔가를하기 위해 앱의 공유 환경 설정을 얻어야합니다. 내 문제는 내가 공유 환경 설정을 얻을 수 없습니다. 내 코드를 먹으 렴 :ArrayAdapter를 확장하는 클래스에서 공유 환경 설정을 얻는 방법 <String>

public class MobileArrayAdapter extends ArrayAdapter<String> { 
private final Context context; 
private final String[] values; 
private static SharedPreferences prefs; 
private String firstBtName = ""; 
private String secondBtName = ""; 
private String thirdBtName = ""; 


public MobileArrayAdapter(Context context, String[] values) { 
    super(context, R.layout.list, values); 
    this.context = context; 
    this.values = values; 

} 

@Override 
public View getView(int position, View convertView, ViewGroup parent) { 

    prefs = getSharedPreferences("MYPREFS", 0); // ERROR ************** 

    LayoutInflater inflater = (LayoutInflater) context 
     .getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
    View rowView = inflater.inflate(R.layout.list, parent, false); 
    TextView textView = (TextView) rowView.findViewById(R.id.label); 
    textView.setText(values[position]); 

ECLIPS 내가 방법의 cind을 해달라고 말한다 ... 은 내가 무엇을 할 수 있습니까? 감사!

답변

11

당신의 오류는 ArrayAdapter와는 getSharedPreferences() 방법이 없기 때문에,이 당신에게 오류를주고 라인 변화 :

prefs = context.getSharedPreferences("MYPREFS", 0); 
+0

우수함! 감사! – roiberg

+0

내 생명이 구원 받았습니다. – busuu

관련 문제