Android progress bar setvisible not working











up vote
0
down vote

favorite












I have problem in seting visibility of Progressbar in a AsyncTask



this is my code:



public class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {

ImageView IV;
FullImageActivity MA;
ProgressBar lp1;

public DownloadImageTask(ImageView IV,
FullImageActivity fullImageActivity) {
this.IV = IV;
this.MA = fullImageActivity;
lp1 = (ProgressBar) MA.findViewById(R.id.progressBar1);
}

protected Bitmap doInBackground(String... p) {
String url = "...";
Bitmap BI = null;
try {
InputStream in = new java.net.URL(url).openStream();
BI = BitmapFactory.decodeStream(in);
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return BI;
}

@Override
protected void onPreExecute() {
lp1.setVisibility(1);
super.onPreExecute();
}

protected void onPostExecute(Bitmap result) {
IV.setImageBitmap(result);
lp1.setVisibility(0);
}
}


and my XML



<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<ImageView
android:id="@+id/full_image_view"
android:layout_width="fill_parent"
android:layout_height="match_parent" />

<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />

</RelativeLayout>


when i use



 lp1.setVisibility(0);


or



 lp1.setVisibility(ProgressBar.GONE); 


or



lp1.setVisibility(View.GONE);


or



lp1.setVisibility(View.INVISIBLE);


my progressBar still visible










share|improve this question




















  • 1




    Why you used progress bar used Progress Dialog instead and dismiss it on onPostExecute(.....)
    – M D
    Mar 4 '14 at 13:05










  • tanx @SimplePlan i use that
    – Hamidreza
    Mar 4 '14 at 14:15















up vote
0
down vote

favorite












I have problem in seting visibility of Progressbar in a AsyncTask



this is my code:



public class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {

ImageView IV;
FullImageActivity MA;
ProgressBar lp1;

public DownloadImageTask(ImageView IV,
FullImageActivity fullImageActivity) {
this.IV = IV;
this.MA = fullImageActivity;
lp1 = (ProgressBar) MA.findViewById(R.id.progressBar1);
}

protected Bitmap doInBackground(String... p) {
String url = "...";
Bitmap BI = null;
try {
InputStream in = new java.net.URL(url).openStream();
BI = BitmapFactory.decodeStream(in);
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return BI;
}

@Override
protected void onPreExecute() {
lp1.setVisibility(1);
super.onPreExecute();
}

protected void onPostExecute(Bitmap result) {
IV.setImageBitmap(result);
lp1.setVisibility(0);
}
}


and my XML



<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<ImageView
android:id="@+id/full_image_view"
android:layout_width="fill_parent"
android:layout_height="match_parent" />

<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />

</RelativeLayout>


when i use



 lp1.setVisibility(0);


or



 lp1.setVisibility(ProgressBar.GONE); 


or



lp1.setVisibility(View.GONE);


or



lp1.setVisibility(View.INVISIBLE);


my progressBar still visible










share|improve this question




















  • 1




    Why you used progress bar used Progress Dialog instead and dismiss it on onPostExecute(.....)
    – M D
    Mar 4 '14 at 13:05










  • tanx @SimplePlan i use that
    – Hamidreza
    Mar 4 '14 at 14:15













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have problem in seting visibility of Progressbar in a AsyncTask



this is my code:



public class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {

ImageView IV;
FullImageActivity MA;
ProgressBar lp1;

public DownloadImageTask(ImageView IV,
FullImageActivity fullImageActivity) {
this.IV = IV;
this.MA = fullImageActivity;
lp1 = (ProgressBar) MA.findViewById(R.id.progressBar1);
}

protected Bitmap doInBackground(String... p) {
String url = "...";
Bitmap BI = null;
try {
InputStream in = new java.net.URL(url).openStream();
BI = BitmapFactory.decodeStream(in);
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return BI;
}

@Override
protected void onPreExecute() {
lp1.setVisibility(1);
super.onPreExecute();
}

protected void onPostExecute(Bitmap result) {
IV.setImageBitmap(result);
lp1.setVisibility(0);
}
}


and my XML



<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<ImageView
android:id="@+id/full_image_view"
android:layout_width="fill_parent"
android:layout_height="match_parent" />

<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />

</RelativeLayout>


when i use



 lp1.setVisibility(0);


or



 lp1.setVisibility(ProgressBar.GONE); 


or



lp1.setVisibility(View.GONE);


or



lp1.setVisibility(View.INVISIBLE);


my progressBar still visible










share|improve this question















I have problem in seting visibility of Progressbar in a AsyncTask



this is my code:



public class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {

ImageView IV;
FullImageActivity MA;
ProgressBar lp1;

public DownloadImageTask(ImageView IV,
FullImageActivity fullImageActivity) {
this.IV = IV;
this.MA = fullImageActivity;
lp1 = (ProgressBar) MA.findViewById(R.id.progressBar1);
}

protected Bitmap doInBackground(String... p) {
String url = "...";
Bitmap BI = null;
try {
InputStream in = new java.net.URL(url).openStream();
BI = BitmapFactory.decodeStream(in);
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return BI;
}

@Override
protected void onPreExecute() {
lp1.setVisibility(1);
super.onPreExecute();
}

protected void onPostExecute(Bitmap result) {
IV.setImageBitmap(result);
lp1.setVisibility(0);
}
}


and my XML



<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<ImageView
android:id="@+id/full_image_view"
android:layout_width="fill_parent"
android:layout_height="match_parent" />

<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />

</RelativeLayout>


when i use



 lp1.setVisibility(0);


or



 lp1.setVisibility(ProgressBar.GONE); 


or



lp1.setVisibility(View.GONE);


or



lp1.setVisibility(View.INVISIBLE);


my progressBar still visible







android android-asynctask progress-bar visibility






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 at 15:39









Cœur

17.2k9102142




17.2k9102142










asked Mar 4 '14 at 13:02









Hamidreza

1,2491824




1,2491824








  • 1




    Why you used progress bar used Progress Dialog instead and dismiss it on onPostExecute(.....)
    – M D
    Mar 4 '14 at 13:05










  • tanx @SimplePlan i use that
    – Hamidreza
    Mar 4 '14 at 14:15














  • 1




    Why you used progress bar used Progress Dialog instead and dismiss it on onPostExecute(.....)
    – M D
    Mar 4 '14 at 13:05










  • tanx @SimplePlan i use that
    – Hamidreza
    Mar 4 '14 at 14:15








1




1




Why you used progress bar used Progress Dialog instead and dismiss it on onPostExecute(.....)
– M D
Mar 4 '14 at 13:05




Why you used progress bar used Progress Dialog instead and dismiss it on onPostExecute(.....)
– M D
Mar 4 '14 at 13:05












tanx @SimplePlan i use that
– Hamidreza
Mar 4 '14 at 14:15




tanx @SimplePlan i use that
– Hamidreza
Mar 4 '14 at 14:15












1 Answer
1






active

oldest

votes

















up vote
0
down vote













 lp1.setVisibility(0);


0 is the value for View.VISIBILE



Here the docs






share|improve this answer





















  • tanx @blackbelt but Still not working
    – Hamidreza
    Mar 4 '14 at 13:22













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f22172716%2fandroid-progress-bar-setvisible-not-working%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













 lp1.setVisibility(0);


0 is the value for View.VISIBILE



Here the docs






share|improve this answer





















  • tanx @blackbelt but Still not working
    – Hamidreza
    Mar 4 '14 at 13:22

















up vote
0
down vote













 lp1.setVisibility(0);


0 is the value for View.VISIBILE



Here the docs






share|improve this answer





















  • tanx @blackbelt but Still not working
    – Hamidreza
    Mar 4 '14 at 13:22















up vote
0
down vote










up vote
0
down vote









 lp1.setVisibility(0);


0 is the value for View.VISIBILE



Here the docs






share|improve this answer












 lp1.setVisibility(0);


0 is the value for View.VISIBILE



Here the docs







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 4 '14 at 13:07









Blackbelt

127k22213240




127k22213240












  • tanx @blackbelt but Still not working
    – Hamidreza
    Mar 4 '14 at 13:22




















  • tanx @blackbelt but Still not working
    – Hamidreza
    Mar 4 '14 at 13:22


















tanx @blackbelt but Still not working
– Hamidreza
Mar 4 '14 at 13:22






tanx @blackbelt but Still not working
– Hamidreza
Mar 4 '14 at 13:22




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f22172716%2fandroid-progress-bar-setvisible-not-working%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Trompette piccolo

Slow SSRS Report in dynamic grouping and multiple parameters

Simon Yates (cyclisme)