
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
thumb_up100%
in an android app . this is javacode to read api from web ,
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity {
privateList<University> universityList;
@Override
protectedvoidonCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
universityList = new ArrayList<>();
String url ="http://universities.hipolabs.com/search?country=Canada";
JsonObjectRequest request =newJsonObjectRequest(Request.Method.GET, url,null,
newResponse.Listener<JSONObject>(){
@Override
publicvoidonResponse(JSONObject response){
try{
JSONArray jsonArray = response.getJSONArray("data");
for(int i =0; i < jsonArray.length(); i++){
JSONObject jsonObject = jsonArray.getJSONObject(i);
String name = jsonObject.getString("name");
String province = jsonObject.getString("state-province");
String webPage = jsonObject.getString("web_page");
University university =newUniversity(name, province, webPage);
universityList.add(university);
}
RecyclerView recyclerView =findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(MainActivity.this));
UniversityAdapter adapter =newUniversityAdapter(universityList);
recyclerView.setAdapter(adapter);
}catch(JSONException e){
e.printStackTrace();
}
}
},newResponse.ErrorListener(){
@Override
publicvoidonErrorResponse(VolleyError error){
Toast.makeText(MainActivity.this,"Error fetching data",Toast.LENGTH_SHORT).show();
}
});
// Add the request to the RequestQueue
RequestQueue queue =Volley.newRequestQueue(this);
queue.add(request);
}
privatestaticclassUniversity{
privateString name;
privateString province;
privateString webPage;
publicUniversity(String name,String province,String webPage){
this.name = name;
this.province = province;
this.webPage = webPage;
}
publicStringgetName(){
return name;
}
publicStringgetProvince(){
return province;
}
publicStringgetWebPage(){
return webPage;
}
}
privatestaticclassUniversityAdapterextendsRecyclerView.Adapter<UniversityAdapter.ViewHolder>{
privateList<University> universityList;
publicUniversityAdapter(List<University> universityList){
this.universityList = universityList;
}
@Override
publicViewHolderonCreateViewHolder(ViewGroup parent,int viewType){
View view =LayoutInflater.from(parent.getContext()).inflate(R.layout.university_item, parent,false);
returnnewViewHolder(view);
}
@Override
publicvoidonBindViewHolder(ViewHolder holder,int position){
University university = universityList.get(position);
holder.nameTextView.setText(university.getName());
holder.provinceTextView.setText(university.getProvince());
holder.webPageTextView.setText(university.getWebPage());
}
@Override
publicintgetItemCount(){
return universityList.size();
}
publicstaticclassViewHolderextendsRecyclerView.ViewHolder{
TextView nameTextView;
TextView provinceTextView;
TextView webPageTextView;
'--
create a xml code that can display Name, Province and Web Page Address of the universities and colleges in Canada from this API.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 3 steps

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Please anwser the following question regarding ios app development.arrow_forwardYou are building a chatbot for a restaurant by using the Bot Framework Composer. Users must be able to browse available meal combinations and select the one they want. You need to ensure that the users can use the chatbot to browse images, prices, and descriptions of the food and select a meal combination. What feature should you include? 1. Text 2. card carousel 3. SuggestedAction card 4. Receipt cardarrow_forwardHow would I add a TextWatcher to the following Java calculator app code: package com.example.tipcalculatorv2;import androidx.appcompat.app.AppCompatActivity;import android.content.Context;import android.os.Bundle;import android.view.View;import android.widget.EditText;import android.widget.TextView;import android.widget.Toast;public class MainActivity extends AppCompatActivity {private EditText billEditText;private TextView totalTextView;private EditText tipPercentEditText;private TextView tipTextView;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);billEditText = (EditText) findViewById(R.id.amount_bill);totalTextView = (TextView) findViewById(R.id.amount_total);tipPercentEditText = (EditText) findViewById(R.id.amount_tip_percent);tipTextView = (TextView) findViewById(R.id.amount_tip);}public void calculate(View view) {String…arrow_forward
- Please anwser the following question regarding ios app development.arrow_forwardWhat is the difference between BeanFactory and ApplicationContext?arrow_forwardThe one functionality that Modernizr doesn't provide to browsers is support for styling HTML5 tags, although it does add other missing features.arrow_forward
- When developing a display driver what would you see the differences in comparison to these two implementations below? Explain to me what would be the benefits of pros and cons, when designing a driver to allow users to get our current frame buffer from our display driver.Explain to me pros and cons of the following options below.Option #1SSD1331 display1;auto& framebuffer = Display<display1>::CurrentFramebuffer();Option #2auto& framebuffer display1.CurrentFramebuffer();arrow_forwardPlease anwser the following question regarding ios app development.arrow_forwardCreate a simple 6x6 android snakes and ladders game. Use gridview for layout. Use .java and .xml. for building game.arrow_forward
- Using android studio 1. Assume we have an activity named musicVideo, write the code to launch/start this activity. Paste the code in the box below. 2. In your own words what does the following code do? What is the name of the activity that will be displayed to the user? Button button = (Button) findViewById(R.id.btnLauncher); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { startActivity(new intent(MainActivity.this, clothes.class)); } } 3. What is wrong with the following? Show your fixes below <string name=app_name">TestApp</string> <string name="txtTitle">Testing App<string> <string name="txtTimes">Times</string> </string name="prompt">Select Group</string> <string name="description">This app stores times</string> <string name"btnTimes">Display Times</string>arrow_forwardMobile Programming Take a look at the following mobile app mockup diagram: [Image attached below] MyOfficeBook is an Android-based mobile application prototype to be a Frontend user looking for employee data and storing employee MyOfficeBook 1. You as a developer, explain the UI Fragment component definition in the Android SDK. Then, define a case in the MyOfficeBook app design above where you SHOULD use Fragments and explain in detail how to use Fragments in that case. Mention at least 2 fragments in the above case. 2. Analyze how to design/implement backround services in MyOfficeBook above. What processes should be handled using background services, and explain how the Services are implemented in the MyAddressBook applicationarrow_forwardAs a UI view controller is created, the default function viewDidLoad() is defined. Unless the function is overridden, it can be inherited from its superclass ___________________. Fill in the blank. Assume that user credentials may be available. One of the implementation methods for iPhone access control is to enable or disable UI objects depending on the user's credential. __________ var button: UIButton! // Q16 @IBAction func _________ {_ sender: Any) { // Q17 // do a sequence of actions } It is also known that user credentials may be available in a remote database. The wanted user credentials need to be downloaded from a remote database. While a main thread executing the local processing, because an external database is accessed over the Internet, data accessing is executed in another thread. As the remote data is downloaded in a thread, the data needs to be passed back to the main thread. The following statement ensures that the main thread is updated on the main…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education