进度条ProgressBar使用实例

文件1
importjava.util.ArrayList;
importjava.util.List;
importandroid.app.Activity;
importandroid.app.AlertDialog;
importandroid.app.Dialog;
importandroid.content.Context;
importandroid.content.Intent;
importandroid.os.Bundle;
importandroid.os.CountDownTimer;
importandroid.view.LayoutInflater;
importandroid.view.View;
importandroid.view.ViewGroup;
importandroid.view.Window;
importandroid.widget.AdapterView;
importandroid.widget.ArrayAdapter;
importandroid.widget.LinearLayout;
importandroid.widget.ListView;
importandroid.widget.ProgressBar;
importandroid.widget.TextView;
importandroid.widget.AdapterView.OnItemClickListener;
importcom.sec.android.touchwiz.samples.R;
importcom.sec.android.touchwiz.widget.TwProgressBar;
/**
*@authorhk0725.han
*@version
*@since
*JupiterGUI_검토안_v0.5_091008.pptx(page76~78)
*progresssamplesimplemented
*refertodocumentabovefordesignguide
*
*/
publicclassProgressBarSample1XmlextendsActivity{

//CountDownTimer=newCountDownTimer;

/**
*menulistitemarray
*/
protectedArrayList<String>mArrayListItemsdata=newArrayList<String>();

privateListViewmListView=null;

/**
*menulistadapter
*/
privateProgressBarAdaptermAdapter=null;


/**
*progressbarsamplemenutext
*/
privateString[]mStrings={"ProgressBar+TextViews",
"ProgressBar(filledwithstrokesvertically)",
"ProgressBarundertheTextView",
"CircularindeterminateProgressBaronspecificBGimage",
"AllCircularindeterminateProgressBarsonDifferentBGimage"
};

publicstaticfinalintPROGRESS_BAR_SAMPLE_1=1000;
publicstaticfinalintPROGRESS_BAR_SAMPLE_2=1005;
publicstaticfinalintPROGRESS_BAR_SAMPLE_3=1010;
publicstaticfinalintPROGRESS_BAR_SAMPLE_4=1015;

intticker=10;

//CountDownTimerforprogressingProgressBarofProgressDialog
privateCountDownTimermTimer=null;

/**
*Menulistcreationforselectingexamplesofprogressbar
*/
@Override
publicvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);

setContentView(R.layout.progressbarsample1xml_main);
mListView=(ListView)findViewById(R.id.ListView01);


for(inti=0;i<mStrings.length;i++){
mArrayListItemsdata.add(mStrings<wbr style="line-height:25px">);<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> mAdapter=newProgressBarAdapter(this,R.layout.progressbarsample1xml_row_item,mArrayListItemsdata);<br style="line-height:25px"><br style="line-height:25px"> mListView.setAdapter(mAdapter);<br style="line-height:25px"><br style="line-height:25px"> /**<br style="line-height:25px"> *<br style="line-height:25px"> *Menuselectionhandlerfordisplayingproperprogressbarexample.<br style="line-height:25px"> */<br style="line-height:25px"> mListView.setOnItemClickListener(newOnItemClickListener(){<br style="line-height:25px"> publicvoidonItemClick(AdapterView&lt;?&gt;parent,Viewview,<br style="line-height:25px"> intposition,longid){<br style="line-height:25px"> onListItemClick(mListView,position,id);<br style="line-height:25px"> }<br style="line-height:25px"> });<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> @Override<br style="line-height:25px"><span style="color:#993300; line-height:25px">protectedvoid</span><span style="color:#ff6600; line-height:25px">onPrepareDialog</span>(intid,Dialogdialog){<br style="line-height:25px"> super.onPrepareDialog(id,dialog);<br style="line-height:25px"><br style="line-height:25px"> switch(id){<br style="line-height:25px"> casePROGRESS_BAR_SAMPLE_1:<br style="line-height:25px"> finalTwProgressBarprogressBar=(TwProgressBar)dialog.findViewById(R.id.progressbar);<br style="line-height:25px"> finalTextViewnumberText=(TextView)dialog.findViewById(R.id.progress_number);<br style="line-height:25px"><br style="line-height:25px"> //initializingprogresswhenuserre-enter<br style="line-height:25px"> progressBar.setProgress(0);<br style="line-height:25px"> numberText.setText("("+progressBar.getProgress()+"/"+progressBar.getMax()+")");<br style="line-height:25px"> if(mTimer!=null){<br style="line-height:25px"> mTimer.cancel();<br style="line-height:25px"> }<br style="line-height:25px"><span style="color:#3366ff; line-height:25px">mTimer=newCountDownTimer(5500,50){<br style="line-height:25px"> publicvoidonTick(longmillisUntilFinished){<br style="line-height:25px"></span><span style="color:#0000ff; line-height:25px">progressBar.incrementProgressBy(1);</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">numberText.setText("("+progressBar.getProgress()+"/"+progressBar.getMax()+")");</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px"></span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">}</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">publicvoidonFinish(){<br style="line-height:25px"> //usersetthefinishactionoftimer,inthiscasemaintainlastscreen,sodonoting.<br style="line-height:25px"> //ifuserwanttosomeaction,usermakesomelogicinthisfield<br style="line-height:25px"> }<br style="line-height:25px"> }.start();</span><br style="line-height:25px"> break;<br style="line-height:25px"><br style="line-height:25px"> casePROGRESS_BAR_SAMPLE_2:<br style="line-height:25px"><br style="line-height:25px"> finalProgressBarpBar2=(ProgressBar)dialog.findViewById(R.id.ProgressBar01);<br style="line-height:25px"> finalProgressBarpBar2_Black=(ProgressBar)dialog.findViewById(R.id.ProgressBar02);<br style="line-height:25px"><br style="line-height:25px"> /**<br style="line-height:25px"> *ProgressBar StartorStop<br style="line-height:25px"> *Indeterminatemodefalse=&gt;true<br style="line-height:25px"> *<br style="line-height:25px"> *Sinceitsimpossibletocontroltheprogressbaranimationatoutside,<br style="line-height:25px"> *useindirectwaytostartanimationagainbysettingindeterminatemodefromfalsetotrue<br style="line-height:25px"> *CAUTION:Thiswayisonlyvalidundertheconditionthatprogressbarhasanattributeofandroid:indeterminateOnlyasfalsevalue.<br style="line-height:25px"> */<br style="line-height:25px"> pBar2.setIndeterminate(false);<br style="line-height:25px"> pBar2.setIndeterminate(true);<br style="line-height:25px"><br style="line-height:25px"> pBar2_Black.setIndeterminate(false);<br style="line-height:25px"> pBar2_Black.setIndeterminate(true);<br style="line-height:25px"><br style="line-height:25px"> break;<br style="line-height:25px"><br style="line-height:25px"> casePROGRESS_BAR_SAMPLE_3:<br style="line-height:25px"><br style="line-height:25px"> finalProgressBarSample3ViewprogressView=(ProgressBarSample3View)dialog.findViewById(R.id.downloaingtitle);<br style="line-height:25px"><br style="line-height:25px"> //initializingprogresswhenuserre-enter<br style="line-height:25px"> progressView.setProgress(0);<br style="line-height:25px"> //&amp;#51116;&amp;#51652;&amp;#51077;&amp;#49884;&amp;#44592;&amp;#51316;timer&amp;#44032;&amp;#51316;&amp;#51116;&amp;#54616;&amp;#47732;cancel&amp;#49884;&amp;#53412;&amp;#44256;&amp;#49352;&amp;#47196;timer&amp;#49373;&amp;#49457;(timer&amp;#51032;&amp;#51473;&amp;#48373;&amp;#51228;&amp;#44144;)<br style="line-height:25px"> if(mTimer!=null){<br style="line-height:25px"> mTimer.cancel();<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> mTimer=newCountDownTimer(5000,50){<br style="line-height:25px"> publicvoidonTick(longmillisUntilFinished){<br style="line-height:25px"> progressView.setProgress(progressView.getProgress()+ticker);<br style="line-height:25px"> progressView.invalidate();<br style="line-height:25px"> }<br style="line-height:25px"> publicvoidonFinish(){<br style="line-height:25px"> progressView.setProgress(0);<br style="line-height:25px"> }<br style="line-height:25px"> }.start();<br style="line-height:25px"> break;<br style="line-height:25px"><br style="line-height:25px"> casePROGRESS_BAR_SAMPLE_4:<br style="line-height:25px"><br style="line-height:25px"> finalProgressBarpBar4=(ProgressBar)dialog.findViewById(R.id.ProgressBar01);<br style="line-height:25px"><br style="line-height:25px"> /**<br style="line-height:25px"> *ProgressBar&amp;#50640;&amp;#50732;&amp;#47140;&amp;#51652;Animation&amp;#50640;&amp;#45824;&amp;#54644;&amp;#50808;&amp;#48512;&amp;#50640;&amp;#49436;StartorStop&amp;#44057;&amp;#51008;control&amp;#51060;&amp;#48520;&amp;#44032;&amp;#54616;&amp;#44592;&amp;#46412;&amp;#47928;&amp;#50640;<br style="line-height:25px"> *Indeterminatemodefalse=&gt;true&amp;#47196;setting&amp;#54644;&amp;#49436;animationrestart&amp;#54624;&amp;#49688;&amp;#51080;&amp;#46020;&amp;#47197;&amp;#54632;.<br style="line-height:25px"> *<br style="line-height:25px"> *Sinceitsimpossibletocontroltheprogressbaranimationatoutside,<br style="line-height:25px"> *useindirectwaytostartanimationagainbysettingindeterminatemodefromfalsetotrue<br style="line-height:25px"> *CAUTION:Thiswayisonlyvalidundertheconditionthatprogressbarhasanattributeofandroid:indeterminateOnlyasfalsevalue.<br style="line-height:25px"> *refertoprogressbarsample1xml_sample4_progress.xml<br style="line-height:25px"> */<br style="line-height:25px"> pBar4.setIndeterminate(false);<br style="line-height:25px"> pBar4.setIndeterminate(true);<br style="line-height:25px"><br style="line-height:25px"> break;<br style="line-height:25px"><br style="line-height:25px"> }<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> @Override<br style="line-height:25px"><span style="color:#993300; line-height:25px">protectedDialog</span><span style="color:#ff6600; line-height:25px">onCreateDialog</span>(intid){<br style="line-height:25px"><br style="line-height:25px"> Contextcontext=ProgressBarSample1Xml.this;<br style="line-height:25px"> LayoutInflaterfactory=LayoutInflater.from(this);<br style="line-height:25px"><br style="line-height:25px"> switch(id){<br style="line-height:25px"><br style="line-height:25px"> casePROGRESS_BAR_SAMPLE_1:<br style="line-height:25px"><br style="line-height:25px"> intprogressMax=44;<br style="line-height:25px"><br style="line-height:25px"> AlertDialog.BuilderprogressSample1=newAlertDialog.Builder(context);<br style="line-height:25px"><br style="line-height:25px"> ViewprogressBody=factory.inflate(R.layout.progressbarsample1xml_sample1_body,null);<br style="line-height:25px"> TextViewbodyTitle=(TextView)progressBody.findViewById(R.id.progress1bodytext);<br style="line-height:25px"><br style="line-height:25px"> finalTextViewnumberText=(TextView)progressBody.findViewById(R.id.progress_number);<br style="line-height:25px"><br style="line-height:25px"> finalTwProgressBarprogressBar=(TwProgressBar)progressBody.findViewById(R.id.progressbar);<br style="line-height:25px"><br style="line-height:25px"> /**<br style="line-height:25px"> *TwProgressBar&amp;#50640;&amp;#49436;&amp;#44592;&amp;#48376;&amp;#51201;&amp;#51064;round&amp;#52376;&amp;#47532;&amp;#51648;&amp;#50896;&amp;#54616;&amp;#51648;&amp;#47564;&amp;#50500;&amp;#47000;&amp;#50696;&amp;#51228;&amp;#50752;&amp;#44057;&amp;#51060;image&amp;#47484;set&amp;#54616;&amp;#45716;&amp;#48169;&amp;#48277;&amp;#44428;&amp;#51109;<br style="line-height:25px"> *<br style="line-height:25px"> *usercansetprogressimageandbackgroundprogressimageusingspecificdrawableimage.<br style="line-height:25px"> */<br style="line-height:25px"> progressBar.setProgressDrawable(R.drawable.progressbarsample1xml_sample1_progress_bar);<br style="line-height:25px"> progressBar.setBackgroundDrawable(R.drawable.progressbarsample1xml_sample1_progress_bar_bg);<br style="line-height:25px"> progressBar.setMax(progressMax);<br style="line-height:25px"><br style="line-height:25px"> bodyTitle.setText(R.string.progressbarsample1xml_status_downloding);<br style="line-height:25px"> numberText.setText("("+progressBar.getProgress()+"/"+progressBar.getMax()+")");<br style="line-height:25px"> progressSample1.setView(progressBody);<br style="line-height:25px"><br style="line-height:25px"><br style="line-height:25px"> returnprogressSample1.create();<br style="line-height:25px"><br style="line-height:25px"> /**<br style="line-height:25px"> *@authorhk0725.han<br style="line-height:25px"> *JupiterGUI_&amp;#44160;&amp;#53664;&amp;#50504;_v0.5_091008.pptx78page<br style="line-height:25px"> *refertodocumentabovefordesignguide<br style="line-height:25px"> *&amp;#50504;&amp;#46300;&amp;#47196;&amp;#51060;&amp;#46300;&amp;#44592;&amp;#48376;Winset&amp;#50640;&amp;#49436;&amp;#51060;&amp;#48120;&amp;#51648;&amp;#47564;&amp;#50629;&amp;#45936;&amp;#51060;&amp;#53944;&amp;#54620;ProgressBar&amp;#51228;&amp;#44277;.<br style="line-height:25px"> *<br style="line-height:25px"> *Indeterminatepopupwithhorizontalstyle<br style="line-height:25px"> */<br style="line-height:25px"> casePROGRESS_BAR_SAMPLE_2:<br style="line-height:25px"><br style="line-height:25px"> AlertDialog.BuildercontainerPopup2=newAlertDialog.Builder(context);<br style="line-height:25px"> ViewinflatedBody2=(View)factory.inflate(R.layout.progressbarsample1xml_sample2_progress,null);<br style="line-height:25px"> ProgressBarpBar2=(ProgressBar)inflatedBody2.findViewById(R.id.ProgressBar01);<br style="line-height:25px"> ProgressBarpBar2_1=(ProgressBar)inflatedBody2.findViewById(R.id.ProgressBar02);<br style="line-height:25px"> TextViewtv2=(TextView)inflatedBody2.findViewById(R.id.TextView01);<br style="line-height:25px"><br style="line-height:25px"> tv2.setText(R.string.progressbarsample1xml_loading);<br style="line-height:25px"> pBar2.setIndeterminate(true);<br style="line-height:25px"> pBar2_1.setIndeterminate(true);<br style="line-height:25px"><br style="line-height:25px"> containerPopup2.setView(inflatedBody2);<br style="line-height:25px"><br style="line-height:25px"> returncontainerPopup2.create();<br style="line-height:25px"> /**<br style="line-height:25px"> *authoryh81.jeon<br style="line-height:25px"> *[JupiterGUI_&amp;#44160;&amp;#53664;&amp;#50504;_v0.5_091008]76page<br style="line-height:25px"> *Textbackground&amp;#48176;&amp;#44221;&amp;#50640;Progressimage&amp;#44032;&amp;#45208;&amp;#53440;&amp;#45208;&amp;#45716;&amp;#50696;&amp;#51228;<br style="line-height:25px"> *<br style="line-height:25px"> *ExampleofProgressBarundertheTextView<br style="line-height:25px"> */<br style="line-height:25px"> casePROGRESS_BAR_SAMPLE_3:<br style="line-height:25px"><br style="line-height:25px"> AlertDialog.BuilderprogressSampele3=newAlertDialog.Builder(context);<br style="line-height:25px"><br style="line-height:25px"> ViewprogressTextBody=factory.inflate(R.layout.progressbarsample1xml_sample3_body,null);<br style="line-height:25px"> ProgressBarSample3ViewtextBody=(ProgressBarSample3View)progressTextBody.findViewById(R.id.downloaingtitle);<br style="line-height:25px"> textBody.setText(R.string.progressbarsample1xml_downloading);<br style="line-height:25px"> textBody.setProgress(0);<br style="line-height:25px"> progressSampele3.setView(progressTextBody);<br style="line-height:25px"><br style="line-height:25px"> returnprogressSampele3.create();<br style="line-height:25px"> /**<br style="line-height:25px"> *hk0725.han<br style="line-height:25px"> *[JupiterGUI_&amp;#44160;&amp;#53664;&amp;#50504;_v0.5_091008]page76-2<br style="line-height:25px"> *refertodocumentabovefordesignguide<br style="line-height:25px"> *IndeterminateProgress&amp;#51060;&amp;#48120;&amp;#51648;&amp;#52628;&amp;#54980;release&amp;#54980;&amp;#50640;&amp;#44368;&amp;#52404;&amp;#50696;&amp;#51221;<br style="line-height:25px"> *progressimagewillbereplacedwhenUXteamreleasenewone.<br style="line-height:25px"> *<br style="line-height:25px"> *Indeterminatepopupwithdefaultstyle.<br style="line-height:25px"> */<br style="line-height:25px"> casePROGRESS_BAR_SAMPLE_4:<br style="line-height:25px"><br style="line-height:25px"> DialogdialogCreated=newDialog(context);<br style="line-height:25px"><br style="line-height:25px"> ViewinflatedBody=(View)factory.inflate(R.layout.progressbarsample1xml_sample4_progress,null);<br style="line-height:25px"> ProgressBarpBar4=(ProgressBar)inflatedBody.findViewById(R.id.ProgressBar01);<br style="line-height:25px"><br style="line-height:25px"> TextViewtv4=(TextView)inflatedBody.findViewById(R.id.TextView01);<br style="line-height:25px"><br style="line-height:25px"> tv4.setText(R.string.progressbarsample1xml_settingwallpaper);<br style="line-height:25px"> pBar4.setIndeterminate(true);<br style="line-height:25px"><br style="line-height:25px"> //Tomakethepopupalignedverticallycenter,needtosetnotitlefeature<br style="line-height:25px"> dialogCreated.requestWindowFeature(Window.FEATURE_NO_TITLE);<br style="line-height:25px"><br style="line-height:25px"> dialogCreated.setContentView(inflatedBody);<br style="line-height:25px"> dialogCreated.getWindow().setBackgroundDrawableResource(R.color.transparent_color);<br style="line-height:25px"><br style="line-height:25px"> returndialogCreated;<br style="line-height:25px"> }<br style="line-height:25px"> returnnull;<br style="line-height:25px"> }<br style="line-height:25px"> /**<br style="line-height:25px"> *Showprogressbarexampleasperuserselectiononlist<br style="line-height:25px"> */<br style="line-height:25px"> protectedvoidonListItemClick(ListViewl,intposition,longid){<br style="line-height:25px"><br style="line-height:25px"> switch(position){<br style="line-height:25px"> case0:<br style="line-height:25px"> showDialog(PROGRESS_BAR_SAMPLE_1);<br style="line-height:25px"> break;<br style="line-height:25px"><br style="line-height:25px"> case1:<br style="line-height:25px"> showDialog(PROGRESS_BAR_SAMPLE_2);<br style="line-height:25px"> break;<br style="line-height:25px"><br style="line-height:25px"> case2:<br style="line-height:25px"> showDialog(PROGRESS_BAR_SAMPLE_3);<br style="line-height:25px"> break;<br style="line-height:25px"><br style="line-height:25px"> case3:<br style="line-height:25px"> showDialog(PROGRESS_BAR_SAMPLE_4);<br style="line-height:25px"> break;<br style="line-height:25px"> case4:<br style="line-height:25px"> startActivity(newIntent(this,ProgressBarSample5Activity.class));<br style="line-height:25px"> break;<br style="line-height:25px"> }<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> privateclassProgressBarAdapterextendsArrayAdapter&lt;String&gt;{<br style="line-height:25px"> privateintmResourceID;<br style="line-height:25px"> privateLayoutInflatermVi;<br style="line-height:25px"> publicProgressBarAdapter(Contextcontext,intresourceID,List&lt;String&gt;objects){<br style="line-height:25px"> super(context,resourceID,objects);<br style="line-height:25px"> mResourceID=resourceID;<br style="line-height:25px"> mVi=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> /**<br style="line-height:25px"> *Listitem&amp;#50640;&amp;#54644;&amp;#45817;&amp;#46104;&amp;#45716;View&amp;#47484;customization&amp;#54644;&amp;#49436;return&amp;#54632;.<br style="line-height:25px"> *convertView&amp;#45716;&amp;#44592;&amp;#51316;&amp;#50640;&amp;#49373;&amp;#49457;&amp;#54620;View&amp;#51116;&amp;#49324;&amp;#50857;&amp;#49884;&amp;#44592;&amp;#49373;&amp;#49457;View&amp;#44032;&amp;#45336;&amp;#50612;&amp;#50740;.<br style="line-height:25px"> *<br style="line-height:25px"> *Customizelistiteminthewaythatiwantittolookandreturnlistitem<br style="line-height:25px"> *convertViewisrecycledviewthatwecanuseagaininsteadofinflatingnewview.<br style="line-height:25px"> */<br style="line-height:25px"> @Override<br style="line-height:25px"> publicViewgetView(finalintposition,ViewconvertView,ViewGroupparent){<br style="line-height:25px"><br style="line-height:25px"> LinearLayoutItemView;<br style="line-height:25px"><br style="line-height:25px"> Stringitem=getItem(position);<br style="line-height:25px"><br style="line-height:25px"> if(convertView==null){<br style="line-height:25px"> ItemView=(LinearLayout)mVi.inflate(mResourceID,parent,false);<br style="line-height:25px"> }else{<br style="line-height:25px"> ItemView=(LinearLayout)convertView;<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> TextViewt1=(TextView)ItemView.findViewById(R.id.TextView01);<br style="line-height:25px"> t1.setText(item);<br style="line-height:25px"><br style="line-height:25px"> returnItemView;<br style="line-height:25px"> }<br style="line-height:25px"> }<br style="line-height:25px"> }<br style="line-height:25px"><span style="line-height:25px">文件2</span>:<br style="line-height:25px"> importandroid.content.Context;<br style="line-height:25px"> importandroid.graphics.Canvas;<br style="line-height:25px"> importandroid.graphics.Rect;<br style="line-height:25px"> importandroid.graphics.drawable.Drawable;<br style="line-height:25px"> importandroid.util.AttributeSet;<br style="line-height:25px"> importandroid.widget.TextView;<br style="line-height:25px"> importcom.sec.android.touchwiz.samples.R;<br style="line-height:25px"> publicclassProgressBarSample3ViewextendsTextView{<br style="line-height:25px"> privateintmProgress;<br style="line-height:25px"> privateintmWindowWidth;<br style="line-height:25px"><br style="line-height:25px"> inti=0;<br style="line-height:25px"><br style="line-height:25px"> publicProgressBarSample3View(Contextcontext){<br style="line-height:25px"> super(context);<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> publicProgressBarSample3View(Contextcontext,AttributeSetattrs){<br style="line-height:25px"> super(context,attrs);<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> publicvoidsetProgress(int_progress){<br style="line-height:25px"> mProgress=_progress;<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> publicintgetProgress(){<br style="line-height:25px"> returnmProgress;<br style="line-height:25px"> }<br style="line-height:25px"> @Override<br style="line-height:25px"> protectedvoidonDraw(Canvascanvas){<br style="line-height:25px"><br style="line-height:25px"> mWindowWidth=getWidth();<br style="line-height:25px"><br style="line-height:25px"> Drawableforeground=getContext().getResources().getDrawable(R.drawable.progressbarsample1xml_sample3_progress_bg);<br style="line-height:25px"> Drawablebackground=getContext().getResources().getDrawable(R.drawable.progressbarsample1xml_sample3_progress_list_bg);<br style="line-height:25px"><br style="line-height:25px"> Rectrect=newRect();<br style="line-height:25px"> Rectrect2=newRect();<br style="line-height:25px"><br style="line-height:25px"> if(mProgress&lt;=mWindowWidth){<br style="line-height:25px"> rect.set(0,0,mProgress+65,getHeight());<br style="line-height:25px"> }<br style="line-height:25px"> else{<br style="line-height:25px"> rect.set(0,0,mWindowWidth+65,getHeight());<br style="line-height:25px"> }<br style="line-height:25px"> rect2.set(0,0,mWindowWidth+65,getHeight());<br style="line-height:25px"><br style="line-height:25px"> foreground.setBounds(rect);<br style="line-height:25px"> background.setBounds(rect2);<br style="line-height:25px"><br style="line-height:25px"> foreground.draw(canvas);<br style="line-height:25px"> background.draw(canvas);<br style="line-height:25px"><br style="line-height:25px"> super.onDraw(canvas);<br style="line-height:25px"> }<br style="line-height:25px"> }<br style="line-height:25px"><span style="line-height:25px">文件三</span>:<br style="line-height:25px"> importcom.sec.android.touchwiz.samples.R;<br style="line-height:25px"> importandroid.app.Activity;<br style="line-height:25px"> importandroid.os.Bundle;<br style="line-height:25px"><span style="color:#993300; line-height:25px">publicclass</span><span style="color:#ff6600; line-height:25px">ProgressBarSample5Activit</span>yextendsActivity{<br style="line-height:25px"><br style="line-height:25px"> @Override<br style="line-height:25px"> publicvoidonCreate(BundlesavedInstanceState){<br style="line-height:25px"> super.onCreate(savedInstanceState);<br style="line-height:25px"><br style="line-height:25px"> setContentView(R.layout.progressbarsample1xml_sample5);<br style="line-height:25px"><br style="line-height:25px"> }<br style="line-height:25px"> }</wbr>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值