私は現在、ユーザー情報を管理できるAndroidアプリを開発中です。そのために私は登録フォーム(名前、ユーザー名、電子メールとパスワード)を持っていて、ロギング後、私のアプリはトースト( 'ようこそ "ユーザー名"')を表示します。そして今私はいくつかの問題を抱えています...ユーザーがメールアドレス、ユーザー名、パスワードなどの情報を更新できるようにする方法を知らない。私は、ユーザーが自分の情報を更新したい私のLoginActivity.java私UserAreaActivity.javaログイン後のユーザー情報の編集/更新[Android]
public class UserAreaActivity extends Activity {
public ImageView bgNet;
public ImageView bgChat;
public ImageView bgStats;
public ImageView bgGo;
public Button bLogout;
TextView name;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE); // Enlever la barre bleue
setContentView(R.layout.activity_user_area);
name = (TextView) findViewById(R.id.name);
Bundle bundle = getIntent().getExtras();
if (bundle != null)
{
name.setText(" "+bundle.getString("name"));
}
else
{
name.setText("Ajanthan");
}
initGoHome();
initPlay();
initGoStats();
initGoChat();
buttonLogout();
}
@Override
public void onBackPressed() {
return;
}
private void initGoHome() {
bgNet = (ImageView) findViewById(R.id.bgNet);
bgNet.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick (View v) {
Intent intent = new Intent (UserAreaActivity.this, HomeActivity.class);
startActivity(intent);
}
});
}
private void initPlay() {
bgGo = (ImageView) findViewById(R.id.bgGo);
bgGo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick (View v) {
Intent intent = new Intent (UserAreaActivity.this, PlayActivity.class);
startActivity(intent);
}
});
}
private void initGoStats() {
bgStats = (ImageView) findViewById(R.id.bgStats);
bgStats.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick (View v) {
Intent intent = new Intent (UserAreaActivity.this, StatsActivity.class);
startActivity(intent);
}
});
}
private void initGoChat() {
bgChat = (ImageView) findViewById(R.id.bgChat);
bgChat.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick (View v) {
Intent intent = new Intent (UserAreaActivity.this, ChatActivity.class);
startActivity(intent);
}
});
}
private void buttonLogout() {
bLogout = (Button) findViewById(R.id.bLogout);
bLogout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick (View v) {
Intent intent = new Intent (UserAreaActivity.this, MainActivity.class);
startActivity(intent);
}
});
}
そして、私のUserAreaActivityの絵の
public class LoginActivity extends Activity {
public ImageView bgLogo;
Button login_button;
EditText Username, Password;
String username, password;
String login_url = "http://192.168.0.19/login.php";
AlertDialog.Builder builder;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE); // Enlever la barre bleue
setContentView(R.layout.activity_login);
initExit();
builder = new AlertDialog.Builder(LoginActivity.this);
login_button = (Button) findViewById(R.id.bLogin);
Username = (EditText) findViewById(R.id.etUsername);
Password = (EditText) findViewById(R.id.etPassword);
login_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
username = Username.getText().toString();
password = Password.getText().toString();
if (username.equals("") || password.equals("")) {
builder.setTitle("Mince une erreur...");
displayAlert("Veuillez entrer un username et un mot de passe correct...");
}
else {
StringRequest stringRequest = new StringRequest(Request.Method.POST, login_url,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
JSONArray jsonArray = null;
try {
jsonArray = new JSONArray(response);
JSONObject jsonObject = jsonArray.getJSONObject(0);
String code = jsonObject.getString("code");
if (code.equals("login_failed")) {
builder.setTitle("Erreur d'authentification");
displayAlert(jsonObject.getString("message"));
}
else {
Intent intent = new Intent (getBaseContext(), UserAreaActivity.class);
Bundle bundle = new Bundle();
bundle.putString("name", jsonObject.getString("name"));
intent.putExtras(bundle);
startActivity(intent);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(LoginActivity.this, "Erreur", Toast.LENGTH_LONG).show();
error.printStackTrace();
}
})
{
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map <String, String> params = new HashMap<String, String>();
params.put("user_name", username);
params.put("password", password);
return params;
}
};
MySingleton.getInstance(LoginActivity.this).addToRequestque(stringRequest);
}
}
});
}
private void initExit() {
bgLogo = (ImageView) findViewById(R.id.bgLogo1);
bgLogo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick (View v) {
Intent intent = new Intent (LoginActivity.this, MainActivity.class);
startActivity(intent);
}
});
}
public void displayAlert (String message) {
builder.setMessage(message);
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Username.setText("");
Password.setText("");
}
});
AlertDialog alertDialog = builder.create();
alertDialog.show();
}
@Override
public void onBackPressed() {
// do nothing.
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
startActivity(intent);
return;
}
コードの
回答常にあなたはユーザー長押しがユーザ名を取得するためのダイアログを表示し、その後のTextViewと上のユーザーonLongPressリスナーをすることができます