ProfileEditView.java :  » App » hello-road » org » android » Android Open Source

Android Open Source » App » hello road 
hello road » org » android » ProfileEditView.java
package org.android;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class ProfileEditView extends Activity {
  private int userId;
  private TextView login;
  private EditText number;
  private EditText firstname;
  private EditText lastname;
  private EditText address;
  private Button confirm;
  private static final int ACTIVITY_CREATE = 0;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.contact_edit);

    login = (TextView) findViewById(R.id.contactEdit_login);
    firstname = (EditText) findViewById(R.id.contactEdit_firstname);
    lastname = (EditText) findViewById(R.id.contactEdit_lastname);
    number = (EditText) findViewById(R.id.contactEdit_number);
    address = (EditText) findViewById(R.id.contactEdit_address);
    confirm = (Button) findViewById(R.id.contactConfirm);

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
      userId = extras.getInt("userId");
      login.setText(extras.getString("login"));
      firstname.setText(extras.getString("firstname"));
      lastname.setText(extras.getString("lastname"));
      number.setText(extras.getString("number"));
      address.setText(extras.getString("address"));
    }
  
    confirm.setOnClickListener(new View.OnClickListener() {
      public void onClick(View v) {
        // sauvegarde des infos.
        if (number.getText().toString() != "") {
          // mettre le userId  jour aprs rsolution du problme du
          // md5
          int result = WSCommunicator.updateUserInfo(userId,
              firstname
              .getText()
              .toString(), lastname.getText().toString(), number
              .getText().toString(), address.getText().toString());
          if (result == 1) {
            Toast.makeText(getBaseContext(),
                "Datas updated", Toast.LENGTH_SHORT)
                .show();
            goBackToInfoView();
          }
          else
            Toast.makeText(getBaseContext(),
                "Datas update failed.", Toast.LENGTH_SHORT)
                .show();
        }
        else
          Toast.makeText(getBaseContext(),
              "Specify a number please.", Toast.LENGTH_SHORT)
              .show();
      }
    });
  }
  
  private void goBackToInfoView() {
    Intent i = new Intent(this, ProfileInfoView.class);
    i.putExtra("userId", userId);
    startActivityForResult(i, ACTIVITY_CREATE);
  }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.