How can I get my Preferences in a other class than the main (Android)?

Change your constructor to look like this: public ButtonAdapter(Context c) { preferences = PreferenceManager. GetDefaultSharedPreferences(c); filenames = new String { preferences. GetString("buttontext1", "n/a"), preferences.

GetString("buttontext2", "n/a") } } And then change how you're declaring the filenames array at the end of the class to look like this: public String filenames.

What getDefaultSharedPreferences is waiting for is a Context object. So, the easy way to do it in your case, if you followed the tutorial is: preferences = PreferenceManager. GetDefaultSharedPreferences(mContext).

This is my ButtonAdapter code and its not working. Have uesed :preferences = PreferenceManager. GetDefaultSharedPreferences(mContext); import android.content.

Context; import android.content. SharedPreferences; import android.graphics. Color; import android.preference.

PreferenceManager; import android.view. View; import android.view. ViewGroup; import android.widget.

BaseAdapter; import android.widget. Button; import android.widget. GridView; public class ButtonAdapter extends BaseAdapter { SharedPreferences preferences; private Context mContext; // Gets the context so it can be used later public ButtonAdapter(Context c) { mContext = c; } // Total number of things contained within the adapter public int getCount() { return filesnames.

Length; } // Require for structure, not really used in my code. Public Object getItem(int position) { return null; } // Require for structure, not really used in my code. Can // be used to get the id of an item in the adapter for // manual control.

Public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { Button btn; if (convertView == null) { // if it's not recycled, initialize some attributes btn = new Button(mContext); btn. SetLayoutParams(new GridView. LayoutParams(100, 55)); btn.

SetPadding(8, 8, 8, 8); preferences = PreferenceManager. GetDefaultSharedPreferences(mContext); } else { btn = (Button) convertView; } btn. SetText(filesnamesposition); // filenames is an array of strings btn.

SetTextColor(Color. WHITE); btn. SetBackgroundResource(R.drawable.

Button); btn. SetId(position); btn. SetOnClickListener(new MyOnClickListener(position)); return btn; } public String filesnames = { preferences.

GetString("buttontext1", "n/a"), "Text button 2", "Text button 3", "Text button 4", "Text button 5", "Text button 6", "Text button 7", "Text button 8", "Text button 9" }; }.

In recent versions of OS X, including Snow Leopard, open your System Preferences, go to the Network panel, click Advanced... and select the Proxies tab. Add "localhost" (without the quotes) to the Bypass proxy settings box. Proxies for your network connection.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions