Ajout de la préférence « Serveur ».

Ajout d'une information sur l'identité du joueur dans la page de garde.
Changement du nom du bouton « Jeux » -> « Jouer »
This commit is contained in:
Bertrand BRUN 2011-01-20 15:46:43 +01:00
parent bc667f95fe
commit 0602a6a81e
5 changed files with 37 additions and 10 deletions

View File

@ -14,14 +14,27 @@
<Button android:layout_height="wrap_content" android:id="@+id/games"
android:text="@string/games_name" android:layout_width="wrap_content"
android:paddingLeft="60px" android:paddingRight="60px"
android:enabled="false"></Button>
android:enabled="false" />
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content" android:id="@+id/prefs"
android:text="@string/prefs_name" android:layout_below="@+id/games"
android:layout_alignLeft="@+id/games" android:layout_alignRight="@+id/games"></Button>
android:layout_alignLeft="@+id/games" android:layout_alignRight="@+id/games" />
</RelativeLayout>
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_height="wrap_content" android:layout_weight="1"
android:layout_width="fill_parent" android:orientation="vertical">
<TextView android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:textStyle="bold"
android:gravity="center_horizontal" android:text="@+id/login" android:id="@+id/login"></TextView>
<ImageView android:layout_height="wrap_content" android:id="@+id/info"
android:layout_width="wrap_content" android:src="@android:drawable/ic_dialog_info" android:layout_gravity="right" android:layout_weight="5"></ImageView>
</LinearLayout>
</RelativeLayout>
<ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/info" android:layout_weight="1" android:src="@android:drawable/ic_dialog_info" android:layout_gravity="right"></ImageView>
</LinearLayout>

View File

@ -3,5 +3,5 @@
<string name="app_name">PtiClic</string>
<string name="prefs_name">Préférences</string>
<string name="games_name">Jeux</string>
<string name="games_name">Jouer</string>
</resources>

View File

@ -3,8 +3,14 @@
<PreferenceCategory android:title="Connexion">
<EditTextPreference android:title="Login" android:key="login"></EditTextPreference>
<EditTextPreference android:title="Mot de Passe" android:key="passwd"></EditTextPreference>
<EditTextPreference android:title="Login" android:key="login" android:summary=""/>
<EditTextPreference android:title="Mot de Passe" android:key="passwd"/>
</PreferenceCategory>
<PreferenceCategory android:title="Debug">
<EditTextPreference android:title="Serveur" android:key="server"/>
</PreferenceCategory>
</PreferenceScreen>

View File

@ -2,19 +2,27 @@ package org.pticlic;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class Main extends Activity implements OnClickListener {
/** Called when the activity is first created. */
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
((Button)findViewById(R.id.prefs)).setOnClickListener(this);
// On récupère le nom du joueur des préférences.
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
String loginPref = sp.getString("login", "joueur");
((TextView)findViewById(R.id.login)).setText("Login : " + loginPref);
}
@Override

View File

@ -13,5 +13,5 @@ public class Preference extends PreferenceActivity {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.prefs);
}
}