2016-03-19 11 views
0

私は簡単なPHPログインフォームのAndroidコードを書いていますが、私は以下のようなエラーが出ています。 PS:Androidには初めてです。Android Symbolでエラーが見つかりません

Error:(34, 9) error: cannot find symbol variable UserLocalStore 
Error:(37, 38) error: incompatible types: <null> cannot be converted to int 
Error:(38, 31) error: non-static method storeUserData(User) cannot be referenced from a static context 
Error:(39, 31) error: non-static method setUserLoggedIn(boolean) cannot be referenced from a static context 

次のように私のコードは

Login.java 
package techcarty.techcarty.com.techcarty; 

import android.content.Context; 
import android.content.Intent; 
import android.os.Bundle; 
import android.support.design.widget.FloatingActionButton; 
import android.support.design.widget.Snackbar; 
import android.support.v7.app.AppCompatActivity; 
import android.support.v7.widget.Toolbar; 
import android.util.Log; 
import android.view.View; 
import android.widget.Button; 
import android.widget.EditText; 
import android.widget.TextView; 
import android.widget.Toast; 

public class Login extends AppCompatActivity { 

Button bLogin; 
EditText etMobileno, etPassword; 
TextView register,fpass; 

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

    etMobileno=(EditText)findViewById(R.id.etMobileno); 
    etPassword=(EditText)findViewById(R.id.etPassword); 
    bLogin=(Button)findViewById(R.id.bLogin); 
    register=(TextView)findViewById(R.id.register); 
    fpass=(TextView)findViewById(R.id.fpass); 

    UserLocalStore = new UserLocalStore(this); 
    bLogin.setOnClickListener(new View.OnClickListener(){ 
     public void onClick(View v) { 
      User user = new User(null, null); 
      UserLocalStore.storeUserData(user); 
      UserLocalStore.setUserLoggedIn(true); 
      } 
     }); 

    } 


public void onClick(View iq) { 

    switch (iq.getId()) { 
     case R.id.register: 
      startActivity(new Intent(this, Register.class)); 
      break; 
     case R.id.fpass: 
      //toast text begins 
      Context context = getApplicationContext(); 
      CharSequence text = "Still need to develop"; 
      int duration = Toast.LENGTH_SHORT; 

      Toast toast = Toast.makeText(context, text, duration); 
      toast.show(); 
      //toast text ends 
      break; 



     } 
    } 
} 

また私のUserLocalStore.javaファイルが

package techcarty.techcarty.com.techcarty; 
    package techcarty.techcarty.com.techcarty; 

     import android.content.Context; 
     import android.content.Intent; 
     import android.os.Bundle; 
     import android.support.design.widget.FloatingActionButton; 
     import android.support.design.widget.Snackbar; 
     import android.support.v7.app.AppCompatActivity; 
     import android.support.v7.widget.Toolbar; 
     import android.util.Log; 
     import android.view.View; 
     import android.widget.Button; 
     import android.widget.EditText; 
     import android.widget.TextView; 
     import android.widget.Toast; 

public class Login extends AppCompatActivity { 

    Button bLogin; 
    EditText etMobileno, etPassword; 
    TextView register,fpass; 

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

     etMobileno=(EditText)findViewById(R.id.etMobileno); 
     etPassword=(EditText)findViewById(R.id.etPassword); 
     bLogin=(Button)findViewById(R.id.bLogin); 
     register=(TextView)findViewById(R.id.register); 
     fpass=(TextView)findViewById(R.id.fpass); 

     UserLocalStore = new UserLocalStore(this); 
     bLogin.setOnClickListener(new View.OnClickListener(){ 
      public void onClick(View v) { 
       User user = new User(null, null); 
       UserLocalStore.storeUserData(user); 
       UserLocalStore.setUserLoggedIn(true); 
      } 
     }); 

    } 


    public void onClick(View iq) { 

     switch (iq.getId()) { 
      case R.id.register: 
       startActivity(new Intent(this, Register.class)); 
       break; 
      case R.id.fpass: 
       //toast text begins 
       Context context = getApplicationContext(); 
       CharSequence text = "Still need to develop"; 
       int duration = Toast.LENGTH_SHORT; 

       Toast toast = Toast.makeText(context, text, duration); 
       toast.show(); 
       //toast text ends 
       break; 



     } 
    } 
} 

l 
import android.content.Context;l 
import android.content.SharedPreferences;l 
l 
/**l 
* Created by SI on 3/18/2016.l 
*/l 
public class UserLocalStore {l 
    public static final String SP_NAME = "userDetailesl"; 
    SharedPreferences userLocalDatabase;l 
l 
    public UserLocalStore(Context context){l 
     userLocalDatabase = context.getSharedPreferencles(SP_NAME, 0); 
l 
l 
    }l 
    public void storeUserData(User user){l 
     SharedPreferences.Editor spEditor = userLocalDlatabase.edit(); 
     spEditor.putString("name", user.name);l 
     spEditor.putInt("age",user.mobno);l 
     spEditor.putString("password", user.password);l 
     spEditor.commit();l 
    }l 
    public User getLoggedInUser(){l 
     String name = userLocalDatabase.getString("namle", ""); 
     int mobno = userLocalDatabase.getInt("mobno", l-1); 
     String password = userLocalDatabase.getString(l"password", ""); 
l 
     User storedUser = new User(name, password, moblno); 
     return storedUser;l 
    }l 
    public void setUserLoggedIn(boolean loggedIn){l 
     SharedPreferences.Editor spEditor = userLocalDlatabase.edit(); 
     spEditor.putBoolean("loggedIn", loggedIn);l 
     spEditor.commit();l 
    }l 
    public boolean getUserLoggedIn(boolean loggedIn){l 
     if(userLocalDatabase.getBoolean("loggedIn", fallse) == true){ 
      return true;l 
     }else{l 
      return false;l 
     }l 
l 
    }l 
    public void clearUserData(){l 
     SharedPreferences.Editor spEditor = userLocalDlatabase.edit(); 
     spEditor.clear();l 
     spEditor.commit();l 
    }l 
}l 
l 
+0

を作成中UserLocalStoreのための変数名を付けますが含まれている、ありますファイルには、これが含まれています –

+0

あなたは変数名 'UserLocalStore userLocalStore =新しいUserLocalStore(これ); ' –

答えて

0

さらに私のUserLocalSore.javaを対象

関連する問題