Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
General Tech Bugs & Fixes 2 years ago
Posted on 29 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
Hi I working with my android, I have two spinners and using retrofit to populate my spinners. I manage to populate first spinner. But I don't know how to get my second spinner populated under id selected from first spinner. I'm using codeigniter rest controller to pass the id and want to retrieve it using retrofit for second spinner, but I don't know how to do this? Please help me.
I already created Rest Controller by passing the id. Already created ApiInterface. And beans to get details data. First spinner working good.
Declaration
classSpinner = (Spinner) findViewById(R.id.classSpinner); divSpinner = (Spinner) findViewById(R.id.divSpinner); classSpinner.setAdapter(mAdapter); mApiInterface = ApiClient.getClient().create(ApiInterface.class); getAllProvinsi();
ApiInterface
public interface ApiInterface { //first spinner @GET("Testpage/provinsi") Call<GetProvinsi> getProvinsi(); //second spinner that I needed how to pass the id? and get data by id selected from first spinner @GET("Testpage/kotabyprovid/provinsi_id/") Call<GetKota> getKota(); }
GetProvinsi ( First Spinner )
public class GetProvinsi { @SerializedName("result") List<Provinsi> listDataProvinsi; public List<Provinsi> getListDataProvinsi() { return listDataProvinsi; } public void setListDataProvinsi(List<Provinsi> listDataProvinsi) { this.listDataProvinsi = listDataProvinsi; }
}
GetKota ( Second Spinner )
public class GetKota { @SerializedName("result") List<Kota> listDataKota; public List<Kota> getListDataKota() { return listDataKota; } public void setListDataKota(List<Kota> listDataKota) { this.listDataKota = listDataKota; }
First Spinner to get all data. I'm trying to select the id to populate second spinner from the adapter.
private void getAllProvinsi() { Call<GetProvinsi> kontakCall = mApiInterface.getProvinsi(); kontakCall.enqueue(new Callback<GetProvinsi>() { @Override public void onResponse(Call<GetProvinsi> call, Response<GetProvinsi> response) { List REPLY 1 views 0 likes 0 shares Facebook Twitter Linked In WhatsApp
Replace
@GET("Testpage/kotabyprovid/provinsi_id/") Call<GetKota> getKota();
with
@GET("Testpage/kotabyprovid/provinsi_id/{prov_id}") Call<GetKota> getKota(@Path("prov_id") int provId);
Now you can pass id to the method, the retrofit will take care of passing provId to the URL path.
provId
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
General Tech 10 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 9 Answers
General Tech 2 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.