I am trying to display a RecyclerView which initially loads a skeleton view before getting the data from API. In the below example, a simple imageview and a text is being displayed.
<android.support.v7.widget.CardView
android:id="#+id/cv_store_offer_display"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="#+id/img"
android:layout_width="match_parent"
android:layout_height="50dp"
android:scaleType="fitXY"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Foo FOO"/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
I would like to know how to make my Recyclerview show the view even before the image/text is loaded. I am using Picasso to load image. mikepenz FastAdapter for displaying RecyclerView content.
I also tried to use a progressbar as mentioned in https://stackoverflow.com/a/12342168/371557. But progressbar was never shown even if the visibility is set to VISIBLE.
you can use something like
picasso.load(url)
.placeholder( R.drawable.place_holder )
.into(imageView);
<!--You Would Apply Like this-->
Picasso.load(url)
.placeholder( R.drawable.img_place_holder)
.into(imageView);
<!--Use ProgressBar-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/sliding_popup_window"
android:layout_below="#+id/bank_info_toolbar"
>
</android.support.v7.widget.RecyclerView>
<ProgressBar
android:id="#+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
/>
</RelativeLayout>
//Your ProgressBar code
class Synch extends AsynchTask<void, void, void> {
public void onPreExecute() {
//your code
progressBar.setVisibility(View.VISIBLE);
recyclerView.setVisibility(View.GONE);
}
}
public void doinBackground() {
//Your Code
}
public void onPostExecute() {
progressBar.setVisibility(View.GONE);
recyclerView.setVisibility(View.VISIBLE);
}
Related
Hello i'm stcuk by a little problem,
I want to add a new CardView with same set of the first CardView underneath the first Cardview only when i click on my button and this action can be repetable endlessly.
Because i'm beginner in android and i have litterally no idea how to make that.
If anyone can Copy Past this code and help me i will be very happy.
I know the spinner is void but its for after i just want to duplicate this.
my activity :
package com.example.lif.test;
public class testActivity extends AppCompatActivity {
Spinner idSpinnerLance;
EditText idEdtTempsLance;
TextView idTextViewPuissance, textViewTitre;
Button idButtonAdd;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
idSpinnerLance = findViewById(R.id.idSpinnerLance);
idEdtTempsLance = findViewById(R.id.idEdtTempsLance);
textViewTitre = findViewById(R.id.textViewTitre);
idTextViewPuissance = findViewById(R.id.idTextViewPuissance);
idButtonAdd = findViewById(R.id.idButtonAdd);
idButtonAdd.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
}
});
}
}
and my xml code :
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".test.testActivity">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardCornerRadius="10dp"
android:layout_margin="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ajouter une lance :"
android:textColor="?android:textColorPrimary"
android:textSize="15dp"
android:textStyle="bold" />
<Spinner
android:id="#+id/idSpinnerLance"
android:layout_width="150dp"
android:layout_height="47dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Temps :"
android:textColor="?android:textColorPrimary"
android:textSize="15dp"
android:textStyle="bold" />
<EditText
android:id="#+id/idEdtTempsLance"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="phone" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<Button
android:id="#+id/idButtonAdd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="add" />
</LinearLayout>
</ScrollView>
thank you
If those CardView will contain different data you can use a RecyclerView and on button click you can add an item in the list and notify the adapter this will add a new item(here item is your CardView created in a different XML file) on screen.
This could be helpful
and this too
EDITED
The examples in google searches and the android documentation are basic, and my question is more complex.
What I do not know, is how to put multiple components together and turn it into a single component. CardView + LinearLayout + TextView + ImageView = Custom View.
If I have a basic example, of cardview with at least one button and a space for external content. It would be enough for me to figure out how to do the rest. This within the cardview extension class, because I also do not know how the extension will understand where to create the components
EDITED 2
Example
QUESTION
I was trying to create a method of using Cardview with an expandable button, and I was able to do this in XML. But I wanted to be able to create a library so I could reuse it in other cases.
I'll show you the source code of what I did.
Layout XML
<android.support.v7.widget.CardView
android:id="#+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="vertical">
<LinearLayout
android:id="#+id/cwlltitulobtn"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:orientation="horizontal">
<TextView
android:id="#+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#### TITLE OF BUTTON ####"
android:textSize="18sp"
android:textStyle="bold"/>
<ImageView
android:id="#+id/imgarrowdown"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:scaleType="fitEnd"
android:visibility="visible"
app:srcCompat="#drawable/ic_keyboard_arrow_down_black_24dp" />
<ImageView
android:id="#+id/imgarrowup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:scaleType="fitEnd"
android:visibility="gone"
app:srcCompat="#drawable/ic_keyboard_arrow_up_black_24dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/cwllconteudo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:orientation="vertical"
android:visibility="gone">
<!-- ########################################
######## CARDVIEW CONTENT HERE #########
########################################-->
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
Java code
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.cwlltitulobtn).setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
CVOpenCloseBTN();
}
});
}
public void CVOpenCloseBTN(){
ImageView arrowdown = (ImageView) findViewById(R.id.cvimgarrowdown);
ImageView arrowup = (ImageView) findViewById(R.id.cvimgarrowup);
LinearLayout pagecontent = (LinearLayout) findViewById(R.id.cwllconteudo);
if (conteudopage .getVisibility() == View.GONE) {
// it's collapsed - expand it
pagecontent.setVisibility(View.VISIBLE);
arrowdown.setVisibility(View.GONE);
arrowup.setVisibility(View.VISIBLE);
} else {
// it's expanded - collapse it
pagecontent.setVisibility(View.GONE);
arrowdown.setVisibility(View.VISIBLE);
arrowup.setVisibility(View.GONE);
}
}
}
My idea is that I can transform all this part of the xml and java code to be used in this way and faster, than to have to always repeat again:
<br.com.samantabiblioteca.CardView
android:id="#+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="5dp"
app:titulo="#### TITLE OF BUTTON ####">
<!-- ########################################
######### CARDVIEW CONTENT HERE ########
########################################-->
</br.com.samantabiblioteca.CardView>
Is it possible to do this?
I have implemented a layout composed of a CardView inside a CardView using AppCompat Support library for CardView. The first layout is the first layer and the second rests on it. Everything is fine on Lollipop, but as stated by Android dev doc, an extra padding is added in order to create shadows on pre-L versions.
Here is the L version:
and the pre-L version:
I've tried a lot of workarounds from other posts to remove these extra paddings, but nothing worked. I may have missed something but I don't know what.
Here is my layout code (I'm using appcompat-v7 r23):
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="80dp"
android:id="#+id/adapter_line_favorites"
android:clickable="false">
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
card_view:cardPreventCornerOverlap="false"
card_view:contentPadding="0dp"
card_view:cardCornerRadius="4dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="15dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="false"
android:layout_alignParentRight="false"
android:layout_alignParentEnd="false">
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
card_view:cardBackgroundColor="#color/CyanPrimaryDark"
card_view:cardCornerRadius="4dp"
android:id="#+id/line_layout">
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_gravity="center_horizontal">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:id="#+id/line_icon"
android:layout_gravity="center"
android:layout_marginTop="15dp" />
</LinearLayout>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:id="#+id/dropdown"
android:layout_gravity="center_vertical|right"
android:layout_marginRight="20dp"
android:focusableInTouchMode="false"
android:src="#drawable/ic_action_keyboard_arrow_down" />
</FrameLayout>
</android.support.v7.widget.CardView>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/inner_favorite"
android:visibility="gone">
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
If anyone has a good workaround working on L and pre-L versions I'm more than interested!
The problem is that you are using CardView from the support library. This Cardview uses its own padding/shadow mechanism on pre-L (api21.) The only way to fix this is to have your adapter use different card layouts for pre-L devices.
Similar question here.
Here is an example, notice the method "determineLayout()" in createviewholder.
public class adapter_overview extends RecyclerView.Adapter<adapter_overview.AdapterViewHolder>{
public ArrayList<String> vehicleList = new ArrayList<>();
private View itemView;
public adapter_overview(ArrayList<String> vehicleList) {
this.vehicleList.addAll(vehicleList.values());
}
#Override
public int getItemCount() {
return vehicleList.size();
}
#Override
public AdapterViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
itemView = LayoutInflater
.from(viewGroup.getContext())
.inflate(determineLayout(), viewGroup,
return new AdapterViewHolder(itemView);
}
#Override
public void onBindViewHolder(AdapterViewHolder adapterViewHolder, int i) {
//do bind stuff
}
}
public int determineLayout(){
if(Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT ){
return R.layout.card_overview_v19;
}else{
return R.layout.card_overview;
}
}
public static class AdapterViewHolder extends RecyclerView.ViewHolder{
public AdapterViewHolder(View view) {
super(view);
//set up text view/etc
}
}
}
I'm using Shared Elements Transition between an imageView in a gridView adapter and an imageView in a details activity , but when i click on an item in the GridView the imageView dosen't start to animate from the right position it always starts under the original place, and when i hit back the image animates to the right place correctly so the glitch happens only when entering the new activity.
https://youtu.be/cprBHWPVNbk (i've slowed down the animation so that the glitch is clear).
In the BrowseFragment's OnCreate :
gridView.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
ImageView gridPoster = (ImageView) view.findViewById(R.id.movie_poster);
gridPoster.setTransitionName("poster" + position);
listener.onItemSelected(movie,gridPoster);
Then the BrowseActivity's listener starts the detailsActivtiy :
ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation
(this, posterView,posterView.getTransitionName());
Intent detailsIntent = new Intent(this, MovieDetalisActivity.class);
detailsIntent.putExtra(getString(R.string.movie_details_extra_key), movie);
detailsIntent.putExtra("transition",posterView.getTransitionName());
ActivityCompat.startActivity(this, detailsIntent, optionsCompat.toBundle());
Then in the DetailsFragment's OnCreate :
ImageView poster = (ImageView) rootView.findViewById(R.id.poster);
poster.setTransitionName(getActivity().getIntent().getStringExtra("transition"));
GridViewItem layout :
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:id="#+id/gird_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:background="#4e585c"
android:clipChildren="false">
<ImageView
android:layout_width="match_parent"
android:layout_height="240dp"
android:id="#+id/movie_poster" />
<RelativeLayout
android:id="#+id/thumb_bottom_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="48dp"
android:gravity="center_vertical">
<TextView
android:id="#+id/movie_name"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:fontFamily="sans-serif"
android:textColor="#aaa"
android:textSize="16sp"
/>
</RelativeLayout>
</LinearLayout>
Part of the DetailsView layout :
<android.support.v4.widget.NestedScrollView
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="#+id/scrollView"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:clipChildren="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context="com.example.rashwan.popularmovies.MovieDetailsActivityFragment"
android:orientation="vertical"
android:focusableInTouchMode="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="310dp"
android:orientation="horizontal"
android:padding="10dp"
android:baselineAligned="false"
android:clipChildren="false">
<FrameLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:clipChildren="false">
<ImageView
android:layout_width="wrap_content"
android:minWidth="220dp"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal"
android:id="#+id/poster" />
</FrameLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:padding="5dp"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ReleaseDate"
android:id="#+id/release_date"
android:layout_gravity="center_horizontal"
android:textAppearance="?android:attr/textAppearanceLarge"
android:padding="5dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="UserRating"
android:id="#+id/user_rating"
android:layout_gravity="center_horizontal"
android:textAppearance="?android:textAppearanceLarge"/>
</LinearLayout>
</LinearLayout>
And in my Theme i declared <item name="android:windowContentTransitions">true</item>i'm not using any custom animation although i tried some and i also tried to postpone the transition but nothing solved the problem.
I've found that the problem was that i'm using picasso library to load the images in the details fragment so i needed to use postponeEnterTransition(); in the details activity then in the details fragment i use getActivity().startPostponedEnterTransition(); to start the transition but only after the image is loaded using picasso.
Here's the code in the details fragment:
Picasso.with(getActivity()).load(posterUri).fit().into(poster, new Callback() {
#Override
public void onSuccess() {
poster.getViewTreeObserver().addOnPreDrawListener(
new ViewTreeObserver.OnPreDrawListener() {
#Override
public boolean onPreDraw() {
if (isLollipop) {
poster.getViewTreeObserver().removeOnPreDrawListener(this);
getActivity().startPostponedEnterTransition();
}
return true;
}
});
}
Try putting your classes in manifest.AS
I have a view with EditText, Button and ListView.
Button's onClick() parses some site (this part works OK), but it takes some time to display the parsed info in ListView, so I want to display small ProgressBar on the place, where the ListView should take place after a while.
So, I add this to my layout (I write important part here):
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/layout1"
android:weightSum="1.0">
<EditText
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight=".86" />
<ImageButton
android:layout_height="match_parent"
android:layout_width="0px"
android:layout_weight=".14" />
</LinearLayout>
<RelativeLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_below="#id/layout1"
android:gravity="center"
android:layout_centerInParent="true"
android:id="#+id/progressbar" >
<ProgressBar
android:layout_height="wrap_content"
android:layout_width="wrap_content"
style="#android:style/Widget.ProgressBar.Small" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/layout1">
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
</RelativeLayout>
In source code:
progressBar = (RelativeLayout) findViewById(R.id.progressbar);
And everytime I want to show the ProgressBar, I do this:
progressBar.setVisibility(View.VISIBLE);
for disabling:
progressBar.setVisibility(View.INVISIBLE);
But this doesn't work.
How can I work this out?
There's no need to manipulate your ProgressBar's visibility. ListView has a feature called "empty view" which is shown only if your ListView is empty. Here's what you need to do to use it:
If your activity extends ListActivity, use
android:id="#android:id/list" for your ListView and
android:id="#android:id/empty" for your ProgressBar.
If you don't extend ListActivity, there's a setEmptyView()
method of your ListView, which lets you do the same thing.
The above method fits best if you don't need to empty your ListView (e.g. data is loaded only once, at the activity startup). If you need to set data after that, it is better to use ViewSwitcher, which also has great advantage - it lets you apply transition animation. For details on ViewSwitcher, take a look at this.
Try using an async task like mentioned above.
/**
* this class performs all the work, shows dialog before the work and dismiss it after
*/
public class ProgressTask extends AsyncTask<String, Void, Boolean> {
public ProgressTask(ListActivity activity) {
this.activity = activity;
dialog = new ProgressDialog(context);
}
/** progress dialog to show user that the backup is processing. */
private ProgressDialog dialog;
/** application context. */
private ListActivity activity;
protected void onPreExecute() {
this.dialog.setMessage("Progress start");
this.dialog.show();
}
#Override
protected void onPostExecute(final Boolean success) {
if (dialog.isShowing()) {
dialog.dismiss();
}
//do whatever with your data
}
protected Boolean doInBackground(final String... args) {
try{
//parsing of your website here...
return true;
} catch (Exception e)
Log.e("tag", "error", e);
return false;
}
}
}
You don't need to nest your ProgressBar in another RelativeLayout. Just center it in your main layout and put it at last so it remains at the top.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
// the rest
<ProgressBar
android:id="#+id/progressBar"
android:layout_centerInParent="true"
android:layout_height="wrap_content"
android:layout_width="wrap_content" />
</RelativeLayout>
The RelativeLayout with the ListView is hiding your ProgressBar.Modify the layout like this and see how it goes:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/layout1"
android:weightSum="1.0">
<EditText
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight=".86" />
<ImageButton
android:layout_height="match_parent"
android:layout_width="0px"
android:layout_weight=".14" />
</LinearLayout>
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_below="#id/layout1"/>
<RelativeLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:gravity="center"
android:layout_centerInParent="true"
android:id="#+id/progressbar" >
<ProgressBar
android:layout_height="wrap_content"
android:layout_width="wrap_content"
style="#android:style/Widget.ProgressBar.Small" />
</RelativeLayout>
</RelativeLayout>
Also have a look at one of my answers, for a somewhat similar problem.
For those, who are interested in the answer.
Main tags are only written.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/layout1"
android:weightSum="1.0" >
<EditText
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight=".86" />
<ImageButton
android:layout_height="match_parent"
android:layout_width="0px"
android:layout_weight=".14" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/layout1" >
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/layout1" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/layout1"
android:gravity="center"
android:visibility="gone"
android:background="#DDE7E7E8"
android:id="#+id/pBar" >
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="#android:style/Widget.ProgressBar.Small" />
</LinearLayout>
</RelativeLayout>
And the AsyncTask:
private class Parsing extends AsyncTask<Void, Void, Void>
{
private LinearLayout pBar;
private Parsing()
{
pBar = (LinearLayout) findViewById(R.id.pBar);
}
#Override
protected Void doInBackground(Void... params)
{
parsingHere();
return null;
}
#Override
protected void onPreExecute()
{
super.onPreExecute();
pBar.setVisibility(View.VISIBLE);
}
#Override
protected void onPostExecute(Void result)
{
super.onPostExecute(result);
pBar.setVisibility(View.INVISIBLE);
}
}