2
I would like to know how I can update a listView
from a button on action bar. By clicking this would be updated by taking the data again from the site https://parse.com. This listview
picks up website data https://parse.com and implement the data.
I’m using the methods: RemoteDataTask
AsyncTask
and the onPostExecute
.
Adapter Code
public class ListViewAdapter extends BaseAdapter {
// Declare Variables
Context context;
LayoutInflater inflater;
ImageLoader imageLoader;
private List<WorldPopulation> worldpopulationlist = null;
private ArrayList<WorldPopulation> arraylist;
public ListViewAdapter(Context context,
List<WorldPopulation> worldpopulationlist) {
this.context = context;
this.worldpopulationlist = worldpopulationlist;
inflater = LayoutInflater.from(context);
this.arraylist = new ArrayList<WorldPopulation>();
this.arraylist.addAll(worldpopulationlist);
imageLoader = new ImageLoader(context);
}
public class ViewHolder {
TextView rank;
TextView country;
TextView population;
ImageView flag;
}
@Override
public int getCount() {
return worldpopulationlist.size();
}
@Override
public Object getItem(int position) {
return worldpopulationlist.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
public View getView(final int position, View view, ViewGroup parent) {
final ViewHolder holder;
if (view == null) {
holder = new ViewHolder();
view = inflater.inflate(R.layout.activity_item_ofertas, null);
// Locate the TextViews in listview_item.xml
holder.rank = (TextView) view.findViewById(R.id.rank);
holder.country = (TextView) view.findViewById(R.id.country);
holder.population = (TextView) view.findViewById(R.id.population);
// Locate the ImageView in listview_item.xml
holder.flag = (ImageView) view.findViewById(R.id.flag);
view.setTag(holder);
} else {
holder = (ViewHolder) view.getTag();
}
// Set the results into TextViews
holder.rank.setText(worldpopulationlist.get(position).getRank());
holder.country.setText(worldpopulationlist.get(position).getCountry());
holder.population.setText(worldpopulationlist.get(position)
.getPopulation());
// Set the results into ImageView
imageLoader.DisplayImage(worldpopulationlist.get(position).getFlag(),
holder.flag);
return view;
}
}
Is andorid certain?
– Jorge B.
@Fernando don’t know if it’s Android...
– Jorge B.
Opa @Jorgeb.,
ListView
,ActionBar
,AsyncTask
andonPostExecute
, I don’t know if other technologies have "components" with the same name? But we can undo the editing in case of doubt, and wait for the AP to pronounce.– Fernando Leal
@Fernando Deixa ficar, mal will not do. I also put the tag but then I took it. Leave it like this and then see.
– Jorge B.
Eh Android yes. That was the question?
– Rony Sueliton
@Jorge B. Eh Android yes what I’m using, and I’m having this doubt to update my listview from a boot in the action bar.
– Rony Sueliton
It was only to edit your question with the Android tag, which is already. But I can not answer your question.
– Jorge B.
@Jorge B. I understood sorry. Could I update Activity from the button in the action bar? Pq tbm would help.
– Rony Sueliton