Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8144035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:15:55+00:00 2026-06-06T13:15:55+00:00

Hi Does anyone know how to create a refresh button that when pressed it

  • 0

Hi Does anyone know how to create a refresh button that when pressed it shows a loading spinner and then when its stopped goes back to the button?

heres what ive got so far

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    //Check Preferences which sets UI

    checkPreferences();
   PostTask posttask;
   posttask = new PostTask();
   posttask.execute();

   Button backbtn = (Button) findViewById(R.id.backbtn);

    //Listening to button event
    backbtn.setOnClickListener(new View.OnClickListener() {

        public void onClick(View arg0) {
            //Starting a new Intent
            Intent previousScreen = new Intent(getApplicationContext(), ChooseTeamActivity.class);
            ChosenMethod = "null";
            SharedPreferences preferences = getSharedPreferences("prefs", Context.MODE_PRIVATE);
            SharedPreferences.Editor editor = preferences.edit();
            editor.putString("ChosenMethod", ChosenMethod);            
            editor.commit();
            previousScreen.putExtra("FullData", fulldata);
            startActivity(previousScreen);

        }
    });

    Button refresh = (Button) findViewById(R.id.refresh);

    //Listening to button event
    refresh.setOnClickListener(new View.OnClickListener() {

        public void onClick(View arg0) {
            // TODO Auto-generated method stub

             PostTask posttask;
               posttask = new PostTask();
               posttask.execute();

        }


    });

heres the function i want it to load

public class PostTask extends AsyncTask<Void, String, Boolean> {


    @Override
    protected Boolean doInBackground(Void... params) {
        boolean result = false;


        loadFixtures();
        publishProgress("progress");
        loadResultsFeed();
        publishProgress("progress");
        loadNewsFeed();
        publishProgress("progress");
        return result;
    }

    protected void onProgressUpdate(String... progress) {
        StringBuilder str = new StringBuilder();
            for (int i = 1; i < progress.length; i++) {
                str.append(progress[i] + " ");

            }
    }

        @Override
    protected void onPostExecute(Boolean result) {
        super.onPostExecute(result);
        Log.v("BGThread", "begin fillin data");
         FillData();

      }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T13:15:56+00:00Added an answer on June 6, 2026 at 1:15 pm

    in your xml file make

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >
    
        <Button
            android:id="@+id/refresh"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    
        <ProgressBar
            android:id="@+id/progress"
            style="?android:attr/progressBarStyleSmall"
            android:layout_width="40dip"
            android:layout_height="40dip"
            android:layout_margin="10dip"
            android:visibility="gone" >
        </ProgressBar>
    </RelativeLayout>
    

    then in your PostTask onPreExecute method

    findViewById(R.id.refresh).setVisibility(View.GONE);
    findViewById(R.id.progress).setVisibility(View.VISIBLE);
    

    and on your OnPostExecute

    findViewById(R.id.refresh).setVisibility(View.VISIBLE);
    findViewById(R.id.progress).setVisibility(View.GONE);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know how to create a webpart with a browse button that allows
Does anyone know how to create a texture with a YUV colorspace so that
Does anyone know how I can Dynamically create an installation package that installs files
Does anyone know if it is possible to create a single connection string that
Does anyone know how to create a Joomla component that doesn't create a section
Does anyone know how to create an icon tile layout similar to that of
Arrrgh. Does anyone know how to create a function that's the multibyte character equivalent
Does anyone know how to create a text field that has a UIImage background
Does anyone know how to create a CGGradient that will fill my view, my
Does anyone know how to create an installation project using Visual Studio 2010 that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.