I've looked everywhere for a tutorial, but couldn't find a tutorial that uses ProgressBar
; they all use ProgressDialog
which is simple but not in my need. So, can anyone give me an example? Here's how I am setting the adapter:
setContentView(R.layout.activity_main);
Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
setSupportActionBar(myToolbar);
list = (ListView) findViewById(R.id.list);
adapter = new mainAdapter(this);
list.setAdapter(adapter);
ParseQueryAdapter
getItemView()
class:
@Override
public View getItemView(Campaign campaign, View v, ViewGroup parent) {
if (v == null) {
v = View.inflate(getContext(), R.layout.list_single,null);
}
super.getItemView(campaign, v, parent);
ParseImageView mealImage = (ParseImageView) v.findViewById(android.R.id.icon);
ParseFile photoFile = campaign.getImage();
if (photoFile != null) {
mealImage.setParseFile(campaign.getImage());
mealImage.loadInBackground(new GetDataCallback() {
@Override
public void done(byte[] data, ParseException e) {
// nothing to do
}
});
}
else{
}
TextView titleTextView = (TextView) v.findViewById(R.id.title);
titleTextView.setText(campaign.getTitle());
TextView descriptionTextView = (TextView) v
.findViewById(R.id.description);
descriptionTextView.setText(campaign.getDescription());
return v;
}
Would be a pleasure if you didn't -1 without thinking. Thanks :)
ProgressBar's are pretty simple. In XML, I usually position them inside of a FrameLayout at the same level as the main content, such as a ScrollView. In done()
after your data has been fetched, hide the ProgressBar and show the ScrollView (or whatever view holds your main content). Hope this helps.
EDIT: If fetching images, use INVISIBLE instead of GONE when hiding whatever layout/views contain your images while the ProgressBar is visible; otherwise the size of the images won't be calculated correctly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.