android 2.3.3에 대한 진행 대화 상자를 사용하고 있습니다. 진행 대화 상자의 상태가 "60 % 60/100"형식으로 표시되지만 "60/100"이 아닌 비율 만 표시하려고합니다. 내가 어떻게 해? 도와주세요.진행률 막대 상태를 백분율로 표시하는 방법
11
A
답변
1
this 링크를 방문하십시오.
또한 SDK의 ApiDemos에 설명되어 있습니다. 원하는 예제는 ProgressBar3.java로 이름 지어지고 \ ApiDemos \ src \ com \ example \ android \ apis \ view \
도 찾을 수 있습니다. 대화 상자 테두리를 제거하여 진행 표시 줄이 나타나면 대화 상자 자체를 투명한 뷰/오버레이로 정의 할 수 있습니다 (예제에서도 마찬가지 임).
17
documentation에 따르면,이 동작을 얻을 수 있도록 ProgressDialog
인스턴스 setProgressNumberFormat (null)
를 호출해야
11
이봐, 여기의 sdcard에 파일을 저장하고 진행 표시 줄을 표시 서버에서 파일을 다운로드. 당신이 얻을이 같은
public class XYZ extends Activity {
public static final int DIALOG_DOWNLOAD_PROGRESS = 0;
private Button startBtn;
private ProgressDialog mProgressDialog;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
startBtn = (Button)findViewById(R.id.startBtn);
startBtn.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
startDownload();
}
});
}
private void startDownload() {
String url = "http://.jpg";
new DownloadFileAsync().execute(url);
}
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_DOWNLOAD_PROGRESS:
mProgressDialog = new ProgressDialog(this);
mProgressDialog.setMessage("Downloading file..");
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
mProgressDialog.setCancelable(false);
mProgressDialog.show();
return mProgressDialog;
default:
return null;
}
}
class DownloadFileAsync extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
showDialog(DIALOG_DOWNLOAD_PROGRESS);
}
@Override
protected String doInBackground(String... aurl) {
int count;
try {
URL url = new URL(aurl[0]);
URLConnection conexion = url.openConnection();
conexion.connect();
int lenghtOfFile = conexion.getContentLength();
Log.d("ANDRO_ASYNC", "Lenght of file: " + lenghtOfFile);
InputStream input = new BufferedInputStream(url.openStream());
OutputStream output = new FileOutputStream("/sdcard/some_photo_from_gdansk_poland.jpg");
byte data[] = new byte[1024];
long total = 0;
while ((count = input.read(data)) != -1) {
total += count;
publishProgress(""+(int)((total*100)/lenghtOfFile));
output.write(data, 0, count);
}
output.flush();
output.close();
input.close();
} catch (Exception e) {}
return null;
}
protected void onProgressUpdate(String... progress) {
Log.d("ANDRO_ASYNC",progress[0]);
mProgressDialog.setProgress(Integer.parseInt(progress[0]));
}
@Override
protected void onPostExecute(String unused) {
dismissDialog(DIALOG_DOWNLOAD_PROGRESS);
}
}
}
..
이 내가 인터넷에서 발견 예를 들어 이미지입니다.
이 내 XML 파일입니다
이<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<Button
android:text="Start long running task.."
android:id="@+id/startBtn"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</Button>
</LinearLayout>
+5
이것은 질문에 대한 대답이 아닙니다. – SoroushA
관련 문제
- 1. 플렉스 진행률 막대 설정
- 2. 진행률 막대 C#
- 3. PHP 진행률 막대?
- 4. 진행률 막대 추가
- 5. iOS 5의 진행률 막대 업데이트
- 6. 회전 된 진행률 막대 정렬
- 7. PowerBuilder 불확정 진행률 막대
- 8. 진행률 막대 문제
- 9. CodeIgniter 및 진행률 막대
- 10. wxpython filecopy 진행률 막대
- 11. PHP의 진행률 막대 업로드
- 12. 세로 진행률 막대 Wpf
- 13. WPF 실시간 진행률 막대
- 14. 포트폴리오 항목의 진행률 막대
- 15. 레이블 및 진행률 막대
- 16. mootools 진행률 막대 추가
- 17. CSS 진행률 막대 오류
- 18. 새보기에서 진행률 막대 업데이트
- 19. jQuery 진행률 막대
- 20. 진행률 막대 및 퍼센트
- 21. WPF 진행률 막대
- 22. vb.net의 스레드를 사용하는 진행률 "막대"
- 23. 백분율로 Ajax 로딩 진행률 표시 줄
- 24. 진행률 막대 업데이트로 여러 다운로드를 구현하는 방법 ??
- 25. asp.net gridview 내에서 진행률 막대 열을 추가하는 방법
- 26. 블랙 베리에서 막대 (예 : 볼륨 막대 또는 진행률 막대) 만들기
- 27. Datagridview에서 데이터를로드 할 때 진행률 막대 표시
- 28. WPF의 다중 진행률 막대 상태
- 29. vb.net에서 세로 진행률 막대 만들기
- 30. WPF : 일정하지 않은 진행률 막대?
당신이 언급 한 방법은 API 레벨에 적용 11. 내 10 – Dhanesh
가 :(내가 나쁜 발굴 소스에 코드를했는데 알아 내입니다 그게 정상적인 방법으로 API 10에서 할 수 없다는 것입니다. 나는 안드로이드 4.0.1에서 ProgessDialog 코드 전체를 얻기위한 임시 해결책을 제안 할 수 있으며 내장 버전 대신 사용할 수 있습니다. 안드로이드 "내부"자원이지만 다시 사용할 수있는 소스로도 제공됩니다. – OleGG