Listview with complex item having a microsecond delay when loading - android

I've spent two days trying to find a solution for this problem and couldn't find it anywhere. My problem is: I have a List View in which each item has 4 text views and an ImageView. I'm fetching data from a website using Volley. The data loads normally and when a I scroll down everything works perfectly. The problem is when I scroll back. When I'm scrolling back the images and textviews have a 0.5 delay to appear (First I see the picture of the last item) and then the content is shown. I've already tried recyclerview and listview with viewholder. This "flick" persists in both solutions.
public class BigCategoryListViewAdapter extends BaseAdapter{
private Context context;
private String[] smallCatsList;
private News news;
private ImageLoader imageLoader;
static class myViewHolder{
TextView smallCatName;
RelativeLayout spinner;
ImageView newsImageView;
TextView newsTitle;
TextView newsContent;
}
public BigCategoryListViewAdapter(Context context, String[] smallCatsList){
this.context = context;
this.smallCatsList = smallCatsList;
this.imageLoader = ImageLoader.getInstance();
if(!this.imageLoader.isInited()) { this.imageLoader.init(ImageLoaderConfiguration.createDefault(context));}
}
#Override
public int getCount() {
return smallCatsList.length;
}
#Override
public Object getItem(int position) {
return smallCatsList[position];
}
#Override
public long getItemId(int position) {return 0;} //modificar aqui
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
final myViewHolder mvh;
LayoutInflater inflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.bigcat_listview,null);
mvh = new myViewHolder();
mvh.smallCatName = (TextView) convertView.findViewById(R.id.bigcat_viewpager_smallcat);
mvh.spinner = (RelativeLayout) convertView.findViewById(R.id.spinner);
mvh.newsImageView = (ImageView) convertView.findViewById(R.id.bigcat_viewpager_imageView);
mvh.newsTitle = (TextView) convertView.findViewById(R.id.bigcat_viewpager_news_title);
mvh.newsContent = (TextView) convertView.findViewById(R.id.bigcat_viewpager_content);
convertView.setTag(mvh);
mvh.smallCatName.setText(smallCatsList[position]);
JSONObject params = new JSONObject();
try{
params.put("slug",smallCatsList[position]);
params.put("startIndex", 0);
params.put("endIndex", 0);
}catch (Exception e) {
Log.e(getClass().toString(), "Error setting params for communication with server");
e.printStackTrace();
}
Volley volley = Volley.getVolley(context);
volley.runRequest(Request.Method.POST, VolleyConstants.PROD_URL + VolleyConstants.NEWS_FETCH_ROUTE,
params, new Response.Listener<JSONObject>() {
//---------------------Volley------------------//
#Override
public void onResponse(JSONObject response) {
JSONArray responseArr = null;
try {
responseArr = response.getJSONArray("newsArr");
} catch (Exception e) {
e.printStackTrace();
}
for (int i = 0; i < responseArr.length(); i++) {
try {
JSONObject object = responseArr.getJSONObject(i);
String photoURLString = object.getString("photo");
String titleString = object.getString("title");
String publisherString = object.getString("publisher");
String dateString = object.getJSONObject("date").getString("date");
String contentString = object.getString("contents");
String urlString = object.getString("url");
news = new News(photoURLString, titleString, publisherString, dateString, contentString,urlString);
} catch (Exception e) {
news = new News("Unknown", "Unknown", "Unknown", "Unknown", "Unknown","Unknown");
}
}
//tv2.setText(news.getNewsDate());
mvh.newsContent.setText(news.getNewsContent());
mvh.newsTitle.setText(news.getNewsHead());
//---------------------Image Loading------------------//
try {
URL url = new URL(news.getNewsPic());
imageLoader.loadImage(news.getNewsPic(), new ImageLoadingListener() {
#Override
public void onLoadingStarted(String imageUri, View view) {
}
#Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
}
#Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
mvh.newsImageView.setImageBitmap(loadedImage);
mvh.spinner.setVisibility(View.GONE);
}
#Override
public void onLoadingCancelled(String imageUri, View view) {
}
});
}catch(Exception e){
mvh.newsImageView.setImageDrawable(context.getResources().getDrawable(R.drawable.nopic));
mvh.spinner.setVisibility(View.GONE);
}
}
}, new CustomErrorListener("ERROR"));
return convertView;
}
This is my adapter. My question is if there is a way to remove this delay to show the content? Or is my problem with network or the listview itself?
I just wanna load all the content for once and then the user can scroll up and down without having to refresh the content everytime.

You're loading the content every time getView is called, that's why it's loading like that. Separate the Volley request from the getView, it should be outside of the adapter entirely, not called upon every load of every piece of the list. You have your News Objects, you can pass an ArrayList to the adapter and fill it from there, that will fix your loading issue. Also, you're calling volley in the Main thread instead of a new thread, you should separate the two, and populate the ListView adapter upon completion of the content being loaded.

One, the ViewHolder pattern example should be something more like this:
if (convertView == null) {
convertView = inflater.inflate(R.layout.bigcat_listview,null);
mvh = new myViewHolder();
//... rest of your code
} else {
mvh = (myViewHolder) convertView.getTag();
//... rest of your code
}
Second, the major Volley loading stuff should not be in the adapter, but processed elsewhere beforehand then passed in. This example should help you out a lot.

Related

Updating a GridView triggers android.os.NetworkOnMainThreadException

I have the problem that every time I want to update my gridview in my fragment I get this error:
android.os.NetworkOnMainThreadException
What do I want to achive?
Show a loading gif in my layout until my fragment loads a list from firestore in the background and then set the data to the gridview Adapter and after that just hide the loading gif and show the gridview.
What did I try already?
I tried to fetch the data and set the Adapter in an AsynkTask and Background Thread but I still recive the same error. (Firestore itself is asynchron also)
When does the Error gets triggered?
public void updateAdapterView(JSONArray cards) {
//Error gets triggered here
grid.invalidateViews();
adapter.refresh(cards);
}
Fragment Activity:
//Set Layout for Fragment
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final FrameLayout view = (FrameLayout) inflater.inflate(R.layout.fragment_exchange, container, false);
loadinglayout = view.findViewById(R.id.loadinglayout);
gridlayout = view.findViewById(R.id.gridlayout);
//first time setting Adapter with empty items
adapter = new ExchangeListAdapter(getContext(), cards);
grid = view.findViewById(R.id.grid);
grid.setAdapter(adapter);
grid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent exchangedetail = new Intent(getActivity(), ExchangeDetail.class);
//exchangedetail.putExtra("item", cardslist[+ position]);
getActivity().startActivity(exchangedetail);
}
});
return view;
}
#Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
//get data from firestore
((MainActivity) getActivity()).getCardsList(new BaseAppCompatActivity.OnCardsFilledListener() {
#Override
public void onCardsFilled(final JSONArray cards) {
updateAdapterView(cards);
}
#Override
public void onError(Exception taskException) {
}
});
}
public void updateAdapterView(JSONArray cards) {
grid.invalidateViews();
adapter.refresh(cards);
}
GridView Adapter:
public class ExchangeListAdapter extends BaseAdapter {
private Context mContext;
private JSONArray cards;
public ExchangeListAdapter(Context c, JSONArray cards) {
mContext = c;
this.cards = cards;
}
#Override
public int getCount() {
int length = 0;
if(cards != null) {
length = cards.length();
}
return length;
}
#Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return null;
}
#Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
public void refresh(JSONArray cards)
{
this.cards = cards;
notifyDataSetChanged();
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View grid;
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
grid = new View(mContext);
grid = inflater.inflate(R.layout.item_exchange_list, null);
ImageView imageView = grid.findViewById(R.id.grid_image);
URL url = null;
try {
url = new URL(cards.getJSONObject(position).getString("thumbnail"));
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
Bitmap bmp = null;
try {
bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());
} catch (IOException e) {
e.printStackTrace();
}
imageView.setImageBitmap(bmp);
} else {
grid = convertView;
}
return grid;
}
}
You are attempting to load an image from a URL on the main application thread inside your getView() method.
Add an image-loading library, such as Glide or Picasso, to your project. Then, use that library to load the image. A library like those can:
Handle placeholder images for a loading state
Do the network I/O on a background thread
Scale the image to fit your ImageView while taking up less memory
Deal with ImageView recycling, if the user scrolls while the image is still being loaded

App get crashed when trying to display Data through listview

I'm trying to get data using retrofit2 and display those data using a list passing through as a parameter of Custom adapter. When I store data in a List in onResponse() method, in onResponse() method list have some value. But in oncreate() method its give me null. Though, I declared List as global. When I run the app sometimes its display nothing and sometimes app get crash. I know it's sounds like crazy. But it's happen. so, I want to know, what's wrong with my Code? how can I display data in listview?
Forgive me if something wrong with my question pattern yet this my maiden question at this site.
MainActivity`
public class LaboratoryValues extends AppCompatActivity {
public List<Data> productList = null;
List<Data>arrayList = null;
int size;
String st;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_laboratory_values);
//productList = new ArrayList<Data>();
getInvestigation();
for(int i =0; i < size; i++){
st = arrayList.get(i).getName();
}
System.out.println("Name : "+st);//here print Name : null
ListView lview = (ListView) findViewById(R.id.listview);
ListviewAdapter adapter = new ListviewAdapter(this, arrayList);
lview.setAdapter(adapter);
}
private void getInvestigation() {
/* final ProgressDialog progressDialog = new ProgressDialog(MainActivity.this);
progressDialog.setCancelable(false); // set cancelable to false
progressDialog.setMessage("Please Wait"); // set body
progressDialog.show(); // show progress dialog*/
ApiInterface apiService =
Api.getClient(ApiInterface.BASE_URL).create(ApiInterface.class);
Call<Investigation> investigationCall = apiService.getInvestigation();
investigationCall.enqueue(new Callback<Investigation>() {
#Override
public void onResponse(Call<Investigation> call, Response<Investigation> response) {
arrayList = response.body().getData();
//productList.addAll(arrayList);
size = response.body().getData().size();
for (int i = 0; i < size; i++) {
System.out.println("Name : " + arrayList.get(i).getName());//here printing Name is ok
}
}
#Override
public void onFailure(Call<Investigation> call, Throwable t) {
Toast.makeText(getApplicationContext(),"data list is empty",Toast.LENGTH_LONG).show();
}
});
}
}
Custom Adapter (listviewAdapter)
public class ListviewAdapter extends BaseAdapter {
public List<Data> productList;
Activity activity;
//Context mContext;
public ListviewAdapter(Activity activity, List<Data> productList) {
super();
this.activity = activity;
this.productList = productList;
}
#Override
public int getCount() {
return productList.size();
}
#Override
public Object getItem(int position) {
return productList.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
private class ViewHolder {
TextView name;
TextView normal_finding;
TextView increased;
TextView decreased;
TextView others;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
LayoutInflater inflater = activity.getLayoutInflater();
if (convertView == null) {
convertView = inflater.inflate(R.layout.listview_row, null);
holder = new ViewHolder();
holder.name = convertView.findViewById(R.id.name);
holder.normal_finding =convertView.findViewById(R.id.normal_finding);
holder.increased = convertView.findViewById(R.id.increased);
holder.decreased = convertView.findViewById(R.id.decreased);
holder.others =convertView.findViewById(R.id.others);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
Data item = productList.get(position) ;
holder.name.setText(item.getName());
System.out.println("holderName : "+item.getName() );
holder.normal_finding.setText(item.getNormal_finding());
System.out.println("holderName : "+item.getNormal_finding() );
holder.increased.setText(item.getIncreased());
holder.decreased.setText(item.getDecreased());
holder.others.setText(item.getOthers());
return convertView;
}
}
It's perfectly normal that it dosent work.
putting your method getInvistigation() before the loop does not mean that the response of your request was done
Calling a webservice creates another thread that waits for the server to send the response, sometimes the response takes time depends from the server and the latency of your internet connection.
you simply need to place the treatment (the loop and adapter) inside getInvistagion after getting the data.

The images in my listview changes when I scroll

This is my code:
public class GetAllCategoriesListViewAdapter extends BaseAdapter{
private JSONArray dataArray;
private Activity activity;
private static final String baseUrlForCategoryImage = "link here";
private static LayoutInflater inflater = null;
public GetAllCategoriesListViewAdapter(JSONArray jsonArray, Activity a){
this.dataArray = jsonArray;
this.activity = a;
inflater = (LayoutInflater) this.activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
#Override
public int getCount() {
return this.dataArray.length();
}
#Override
public Object getItem(int position) {
return position;
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
final ListCell cell;
if(convertView == null){
convertView = inflater.inflate(R.layout.get_all_categories_list_view_cell, null);
cell = new ListCell();
cell.category_name = (TextView) convertView.findViewById(R.id.category_name);
cell.category_image = (ImageView) convertView.findViewById(R.id.category_image);
cell.category_image.setTag(cell);
convertView.setTag(cell);
}else{
cell = (ListCell) convertView.getTag();
}
try{
JSONObject jsonObject = this.dataArray.getJSONObject(position);
cell.category_name.setText(jsonObject.getString("category_name"));
String nameOfImage = jsonObject.getString("category_image");
String urlForImageInServer = baseUrlForCategoryImage + nameOfImage;
new AsyncTask<String, Void, Bitmap>(){
protected Bitmap doInBackground(String... params){
String url = params[0];
Bitmap icon = null;
try{
InputStream in = new java.net.URL(url).openStream();
icon = BitmapFactory.decodeStream(in);
}catch (MalformedURLException e){
e.printStackTrace();
}catch (IOException e){
e.printStackTrace();
}
return icon;
}
#Override
protected void onPostExecute(Bitmap result) {
cell.category_image.setImageBitmap(result);
}
}.execute(urlForImageInServer);
}catch (JSONException e){
e.printStackTrace();
}
return convertView;
}
private class ListCell{
private ImageView category_image;
private TextView category_name;
}
}
The code gets the images from my webhost and place it in every cell in my listvew. The problem is everytime I scroll, the images are shuffled and returns in few seconds. How to stop the images from changing when I scroll? I tried to use the solution on other post but it won't work. Please help.
Looks like you are new to android. So you are fetching the images in the getView method. The getView method is called every time a new list item is drawn. So For every image, a new request is made to internet. SO that will be a lot of requests . You should firstly get your images and get them in some ArryayList . Then pass that Arraylist to your adapter. Here is tutorial for you
Using AsyncTask
http://www.devexchanges.info/2015/04/android-custom-listview-with-image-and.html
Using Volley
https://www.androidhive.info/2014/07/android-custom-listview-with-image-and-text-using-volley/
Go for Volley for better performance. Cheers!

Please suggest me on proper usage of notifyDataSetChanged()

I'm using view pager with swiping tab layouts. And i'm displaying list view of data using custom adapter. And also onclick of list view i have a list view detail activity where I'm displaying data in more detail. In these detail activity i'm performing some changes to the data(some post method). after that I create an instance of customAdapter class and call notifyDataSetChanged() in order to refresh list view. My problem over here is the list view some times refreshes quickly and some times there is a delay of some seconds.
So, Can somebody suggest me proper usage of list view and what changes needs to be done in order to refresh list view whenever a post method is performed.
My code Fragment class:
private void showJsonData(String response) {
try {
String serviceID = LoggedInUserStore.getLoggedInServiceId(getContext());
List<Complaint> userList = new ArrayList<>(); //ArrayList of type user(POJO CLASS)
JSONArray jsonArray = new JSONArray(response);
for (int i = 0; i < jsonArray.length(); i++) {
if (serviceID.equals(jsonArray.getJSONObject(i).getString("ServiceID"))) {
if (jsonArray.getJSONObject(i).getString("CallStatusID").equalsIgnoreCase("1")) {
userList.add(0, Complaint.fromJson(jsonArray.getJSONObject(i))); //
}
}
}
assignAdapter = new AssignAdapter(getActivity(), userList);
listView.setAdapter(assignAdapter);
listView.invalidateViews();
assignAdapter.notifyDataSetChanged();
} catch (JSONException e) {
e.printStackTrace();
}
}
My custom adapter class
public class AssignAdapter extends BaseAdapter implements Filterable {
List<Complaint> ticket = new ArrayList<>();
private Context context;
String ticketNo, complaint, raiseDate;
Complaint user;
List<Complaint> temporaryList = new ArrayList<>();
/*String status, priority;*/
public AssignAdapter(Context context, List<Complaint> ticket) {
this.context = context;
this.ticket = ticket;
this.temporaryList = ticket;
}
#Override
public int getCount() {
return temporaryList.size();
}
#Override
public Object getItem(int position) {
return temporaryList.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
public class viewHolderItem {
TextView ticketNumberText, complaintNameText, raisedDateText;
}
//Set the layout for the fragment and return it.
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
viewHolderItem holder;
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.custom_list_view, null, true);
holder = new viewHolderItem();
holder.ticketNumberText = (TextView) convertView.findViewById(R.id.ticketIdSupervisor);
holder.complaintNameText = (TextView) convertView.findViewById(R.id.complaintNameSupervisor);
convertView.setTag(holder);
} else {
holder = (viewHolderItem) convertView.getTag();
}
user = temporaryList.get(position);
if (user != null) {
//Get the Ticket Number
Typeface custom_font = Typeface.createFromAsset(context.getAssets(), "fonts/DroidSerif.ttf");
ticketNo = temporaryList.get(position).getTicketNumber();
holder.ticketNumberText.setText(ticketNo);
holder.ticketNumberText.setTag("ticketNumber");
holder.ticketNumberText.setTypeface(custom_font);
//Get the complaint Name
complaint = temporaryList.get(position).getComplaintDetails();
holder.complaintNameText.setText(complaint);
holder.complaintNameText.setTag("complaint");
holder.complaintNameText.setTypeface(custom_font);
}
convertView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent i = new Intent(context.getApplicationContext(), ComplaintDetailsSupervisor.class);
i.putExtra("COMPLAINT NAME", temporaryList.get(position).getComplaintDetails());
i.putExtra("RAISED DATE", temporaryList.get(position).getRaisedDate().substring(0, 10));
context.startActivity(i);
}
});
notifyDataSetChanged();
return convertView;
}
public void notifyDataSetChanged() {
super.notifyDataSetChanged();
}
}
My List view detail activity class
dialogButtonOk.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
try {
assignComplaint();
al.remove(position);
AssignAdapter assignAdapter = new AssignAdapter(getApplicationContext(), al);
assignAdapter.notifyDataSetChanged();
ComplaintDetailsSupervisor.this.finish();
} catch (JSONException e) {
e.printStackTrace();
}
}
});
dialogButtonNo.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}
}
});
}
public void assignComplaint() throws JSONException {
//my custom method...
}
In the list view detail activity class i'm doing this
al.remove(position);
AssignAdapter assignAdapter = new AssignAdapter(getApplicationContext(), al);
assignAdapter.notifyDataSetChanged();
ComplaintDetailsSupervisor.this.finish();
Removing the position of list view and immediately calling adapter. This works fine but I don't know why sometimes it does not refreshes..May be when list view has a single item it does not refreshes immediately.
You are creating a new adapter and calling notifyDatasetChanged on it but have not called setAdapter with the new adapter as a parameter, hence why your list ist not refreshed.
You need to call
setAdapter(assignAdapter)
or reuse your existing assignAdapter and then call notifyDatasetChanged() on it.

Unlimited scrolling with JSON Adapter & ListView

I'm using ListView that retrieves data from external URL with JSON.
When I run my app, it shows only maximum of 10 results since my api query returns maximum of 10 results PER page.
What i'm trying to do is, that when the user scrolls down to the end of this 10 results, it will load more results (one by one would be even greater) from my JSON external URL (API).
This is how I'm using my ListView & JSONAdapter:
TabFragment1.java
ListView mainListView = (ListView) v.findViewById(R.id.main_listview);
mJSONAdapter = new JSONAdapter(getActivity(), inflater);
mainListView.setAdapter(mJSONAdapter);
getUpdates();
getUpdates()
private void queryUpdates(double lat, double lon, int distance) {
// Create a client to perform networking
AsyncHttpClient client = new AsyncHttpClient();
// Show ProgressBar to inform user that a task in the background is occurring
mProgress.setVisibility(View.VISIBLE);
// Have the client get a JSONArray of data
// and define how to respond
client.get(API_URL + "?lat=" + lat + "&lon=" + lon + "&distance=" + distance,
new JsonHttpResponseHandler() {
#Override
public void onSuccess(JSONObject jsonObject) {
// 11. Dismiss the ProgressDialog
mProgress.setVisibility(View.GONE);
// update the data in your custom method.
mJSONAdapter.updateData(jsonObject.optJSONArray("docs"));
}
#Override
public void onFailure(int statusCode, Throwable throwable, JSONObject error) {
// 11. Dismiss the ProgressDialog
mProgress.setVisibility(View.GONE);
getActivity().setContentView(R.layout.bad_connection);
}
});
}
My JSONAdapter.java
public class JSONAdapter extends BaseAdapter implements StickyListHeadersAdapter {
Context mContext;
LayoutInflater mInflater;
JSONArray mJsonArray;
public JSONAdapter(Context context, LayoutInflater inflater) {
mContext = context;
mInflater = inflater;
mJsonArray = new JSONArray();
}
#Override
public int getCount() {
return mJsonArray.length();
}
#Override
public Object getItem(int position) {
return mJsonArray.optJSONObject(position);
}
#Override
public long getItemId(int position) {
// your particular dataset uses String IDs
// but you have to put something in this method
return position;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
// check if the view already exists
// if so, no need to inflate and findViewById again!
if (convertView == null) {
// Inflate the custom row layout from your XML.
convertView = mInflater.inflate(R.layout.row_place_update, null);
// create a new "Holder" with subviews
holder = new ViewHolder();
holder.myImageView = (ImageView) convertView.findViewById(R.id.myImage);
holder.myTextView = (TextView) convertView.findViewById(R.id.myText);
// hang onto this holder for future recyclage
convertView.setTag(holder);
} else {
// skip all the expensive inflation/findViewById
// and just get the holder you already made
holder = (ViewHolder) convertView.getTag();
}
// More code after this
// Get the current book's data in JSON form
JSONObject jsonObject = (JSONObject) getItem(position);
// Grab the title and author from the JSON
if (jsonObject != null) {
//Get from JSON
String myImage = jsonObject.optString("myImage");
String myText = jsonObject.optString("myText");
//Replace Them
Picasso.with(mContext).load(myImage).placeholder(R.drawable.loading).into(holder.myImageView);
holder.myTextView.setText(myText);
}
return convertView;
}
// this is used so you only ever have to do
// inflation and finding by ID once ever per View
private static class ViewHolder {
public ImageView myImageView;
public TextView myTextView;
}
public void updateData(JSONArray jsonArray) {
// update the adapter's dataset
mJsonArray = jsonArray;
notifyDataSetChanged();
}
}
how I can show more results by adding &page=2, &page=3 to the API_URL and load these results in my ListVIew, in addition to the old results?

Categories

Resources