我想在 Android 中下载应用程序时显示通知栏。我希望栏与从市场下载应用程序时显示的栏相同。请问有什么帮助吗?
问问题
9015 次
2 回答
3
这是download_progress(要更改进度条的样式,请使用您自己的android:progressDrawable
)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:padding="5dp">
<TextView android:id="@+id/status_text" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_alignParentTop="true"
android:text="@string/download_notification_message" />
<ProgressBar android:id="@+id/status_progress"
android:layout_width="fill_parent" android:layout_height="5dp"
android:layout_below="@id/status_text"
android:layout_marginTop="10dp"
android:progressDrawable="@drawable/notification_progress_bar"
style="@android:style/Widget.ProgressBar.Horizontal"
android:indeterminate="false" android:indeterminateOnly="false" /> </RelativeLayout>
通知进度条:
<?xml version="1.0" encoding="utf-8"?><layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<gradient
android:startColor="#000001"
android:centerColor="#0b131e"
android:centerY="0.75"
android:endColor="#0d1522"
android:angle="270"
/>
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<gradient
android:startColor="#234"
android:centerColor="#234"
android:centerY="0.75"
android:endColor="#a24"
android:angle="270"
/>
</shape>
</clip>
</item>
<item
android:id="@android:id/progress">
<clip>
<shape>
<gradient
android:startColor="#44000000"
android:centerColor="#44000000"
android:centerY="0.75"
android:endColor="#44000000"
android:angle="270"
/>
</shape>
</clip>
</item>
于 2012-06-21T09:41:32.037 回答
-2
试试这个通知栏的代码
void showProgress(String file_path){
dialog = new Dialog(DownloadFileDemo1.this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.myprogressdialog);
dialog.setTitle("Download Progress");
TextView text = (TextView) dialog.findViewById(R.id.tv1);
text.setText("Downloading file from ... " + file_path);
cur_val = (TextView) dialog.findViewById(R.id.cur_pg_tv);
cur_val.setText("Starting download...");
dialog.show();
pb = (ProgressBar)dialog.findViewById(R.id.progress_bar);
pb.setProgress(0);
pb.setProgressDrawable(getResources().getDrawable(R.drawable.green_progress));
}
于 2012-06-21T09:43:38.817 回答