Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 通过改型使用两个界面登录_Android_Api_Retrofit - Fatal编程技术网

Android 通过改型使用两个界面登录

Android 通过改型使用两个界面登录,android,api,retrofit,Android,Api,Retrofit,我有两个接口没有相同的属性,我需要它们使用改型登录。如何实现其他界面使用相同的按钮? 我想对IEnfant和IASISTANT接口使用此登录方法: button.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View v) { IEnfant iEnfant= APIClient.getClient().create(IEnfant

我有两个接口没有相同的属性,我需要它们使用改型登录。如何实现其他界面使用相同的按钮? 我想对IEnfant和IASISTANT接口使用此登录方法:

button.setOnClickListener(new View.OnClickListener(){
        @Override
        public void onClick(View v) {


           IEnfant iEnfant= APIClient.getClient().create(IEnfant.class);


           iEnfant.login(editText1.getText().toString(),editText2.getText().toString()).enqueue(new Callback<Enfant>() {
                @Override
                public void onResponse(retrofit2.Call<Enfant> call, Response<Enfant> response) {
                    Toast.makeText(getApplicationContext(),"enfant"+response.body().getNom(),Toast.LENGTH_LONG).show();

                    startActivity(new Intent(getApplicationContext(), CategoriesActivity.class));
                }

                @Override
                public void onFailure(retrofit2.Call<Enfant> call, Throwable t) {
                    Toast.makeText(getApplicationContext(),"'error",Toast.LENGTH_LONG).show();
                    Log.v("tag!!!!!!!!!!","error"+t.getMessage());

                }
            });
button.setOnClickListener(新视图.OnClickListener(){
@凌驾
公共void onClick(视图v){
IEnfant IEnfant=APIClient.getClient().create(IEnfant.class);
iEnfant.login(editText1.getText().toString(),editText2.getText().toString()).enqueue(新回调()){
@凌驾
公共void onResponse(2.Call,Response){
Toast.makeText(getApplicationContext(),“enfant”+response.body().getNom(),Toast.LENGTH_LONG).show();
startActivity(新意图(getApplicationContext(),CategoriesActivity.class));
}
@凌驾
公共失效失效失效(改型2.Call,可丢弃t){
Toast.makeText(getApplicationContext(),“error”,Toast.LENGTH_LONG.show();
Log.v(“tag!!!!!!!!!!!”,“error”+t.getMessage());
}
});
我的意思是我需要在一个活动中进行多次回调,这可能吗? 以下是我的两个界面:

public interface IEnfant {
   @GET ("api/eLogin")
   Call<Enfant> login (@Query("username") String username, @Query("mot_de_passe")  String motDePasse);

}

public interface IAssistant {
   @GET ("api/aLogin")
   Call<Assistant> login (@Query("username") String username, @Query("mot_de_passe")  String motDePasse);

}
公共接口IEnfant{
@获取(“api/eLogin”)
调用登录名(@Query(“username”)字符串username,@Query(“mot_de_passe”)字符串motDePasse);
}
公共接口iAsistant{
@获取(“api/aLogin”)
调用登录名(@Query(“username”)字符串username,@Query(“mot_de_passe”)字符串motDePasse);
}

请提供更多详细信息?两个接口的代码。以及您希望在第二个接口中使用哪种方法?请检查我编辑的帖子。您需要创建两个不同的改装实例并使用IEnfant或IASISTANT。或者您只需在具有两种不同登录方法的接口上使用请提供更多详细信息?两个接口的代码。以及哪一个是m您想在第二个界面中使用的方法?请查看我编辑的帖子。您需要创建两个不同的改装实例,并使用IEnfant或IASISTANT。或者您只需在界面上使用两种不同的登录方法