inherit value from another class in android -


I want to keep the value that is entered in the text edited by the user. So I want to use the value entered in that different category. Basically I want users to enter their username in this category.

  The public class uses Loginpage activity on OnClickListener {EditText Usern, passw, dis; Button ULGIN; String; Override public null at @reate (bundle saved instenestate) {// TODO auto generated method stub super. Connet (Saved Instantstate); setContentView (R.layout.loginpage); User = (Editing Text) SearchVBIID (RID.); Find passw = (edit text) VVBIID (RID.pass); Dis = (EditText) findViewById (R.id.dis); Ulauseine = (button) Find VVBIID (RIDLogin); ulogin.setOnClickListener (this); k = usern.getText () toString (). } @ Override Public Wide Onclick Onclick (see p) {// TODO Auto-Generated Method Stub Switch (P.IGID)} {Case R.Id.Login: K = usern.getText (). ToString (); String passwd = passw.getText (). ToString (); Process cat = new process (this); Cat.open (); String returnpath = cat.getpass (k); Cat.close (); If (passwd.equals (returnpass)) {intent i = new intent ("com.example.billpay.USEROPTION"); startActivity (i); Dialog r = new dialog (this); R.setTitle ("login successful"); TextView wg = new text view (this); Wg.setText ("success"); R.setContentView (WG); R.show (); } Other {Dialog R = New Dialog (this); R.setTitle ("Wrong username or password"); TextView PO = new text view (this); Po.setText ("Failure"); R.setContentView (PO); R.show (); }}}}   

Then I want to use their value which they have entered in the second class in the edited text which is this. I want to display my username in this page Public class Userprofile Loginpage {TextView pra; Public Zero (Bundle Saved InstantState) on the Create {// Todo Auto-Generated Method Stub Super. Connet (Saved Instantstate); SetContentView (R.layout.userprofile); Pra = (TextView) findViewById (R.id.pra); EditText p = usern; String session = P.get text (). ToString (); Pra.setText (K); }}

but I am not able to display their value

< P> In the first category:
  reference c = getApplicationContext (); String user name;   

Once you keep your string with your username:

  intent = new intent (c, YourSecondClass.class); Intent.putExtra ("username", user name); StartActivity;   

In its second category:

  string user name; Bundle bundle = new bundle (); Bundle = getIntent.getExtras (); Username = bundle.getString ("user name"); Edit:  

If the second class is not said directly to the frist, you should use the shared references:

  & Lt; Map & gt; & Lt; String name = "mail" & gt; User@mail.com< / String & gt; & Lt; Tring name = "other" & gt; OtherWebable & lt; / Tring & gt; & Lt; / Map & gt; In the code, to reach that variable, you do this:  
  The public class increases the MainActivity activity {TextView Mail; Reference C; @ Override Protected Zero (Bundle Saved Instantstate) {Super. NET (Saved Instantstate); SetContentView (R.layout.activity_main); C = getApplicationContext (); Enter values ​​in the preferences preferences.xml SharedPreferences prefs = getSharedPreferences ("Preferences", references. MODE_PRIVATE); SharedPreferences.Editor Editor = prefs.edit (); Editor.putString ("mail", "correo@mail.com"); editor.commit (); // preferences.xml string correo = prefs.getString ("mail", blank); Mail = (TextView) findViewById (R.id.mail); Mail.setText (correo); }}    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -