title: android preferences in main layout
body: <p>I have a problem with the preferences.
  I created this simple project :
  start.java:</p>
  
  <pre><code>package example.ex;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.View;
  
  public class start extends Activity {
      Intent intent;
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
      }
      public void preferences (View view){
          intent = new Intent(getApplicationContext(), Preferences.class);
          startActivity(intent);      
      }
  }
  </code></pre>
  
  <p>Preferences.java:</p>
  
  <pre><code>    package example.ex;
  
  import android.os.Bundle;
  import android.preference.PreferenceActivity;
  
  public class Preferences extends PreferenceActivity {
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          addPreferencesFromResource(R.xml.preferences);
      }
  }
  </code></pre>
  
  <p>the main activity is the start, from which we go (via a button) to Preferences.
  Preferences display the preferences( a list with a pop-up) . </p>
  
  <p>Layout : 
  main.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      &gt;
  &lt;TextView  
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="@string/hello"
      /&gt;
      &lt;Button
       android:layout_height="wrap_content"
       android:layout_width="wrap_content"
       android:text="preferences"
       android:onClick="preferences" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>preferenze.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;TableLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
  &gt;
      &lt;TableRow&gt;
          &lt;TextView
                  android:text="List Selection:"
                  android:paddingRight="5px"
          /&gt;
          &lt;TextView android:id="@+id/list"
          /&gt;
      &lt;/TableRow&gt;
  &lt;/TableLayout&gt;
  </code></pre>
  
  <p>in values i put arrays.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;resources&gt;
      &lt;string-array name="country"&gt;
          &lt;item&gt;U.S. (United States of America)&lt;/item&gt;
          &lt;item&gt;Italia (Italy)&lt;/item&gt;
      &lt;/string-array&gt;
      &lt;string-array name="codice_paese"&gt;
          &lt;item&gt;US&lt;/item&gt;
          &lt;item&gt;IT&lt;/item&gt;
      &lt;/string-array&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>Finally, I created a preferences.xml (in a folder xml in res) :</p>
  
  <pre><code>&lt;PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;PreferenceCategory android:title="Simple Preferences"&gt;
          &lt;ListPreference android:key="list" android:title="Selection Dialog"
              android:summary="Click to pop up a list to choose from"
              android:entries="@array/country" android:entryValues="@array/codice_paese"
              android:dialogTitle="Choose a country" /&gt;
      &lt;/PreferenceCategory&gt;
  &lt;/PreferenceScreen&gt;
  </code></pre>
  
  <p>then: I have a main and then I go to a page of Preferences.</p>
  
  <p><strong>I would like to put directly into the main preferences (instead of the button) and use one Activity</strong></p>
  
  <p>but I can not do it in any way ..
  please you have any suggestions?
  thanks!</p>