开发者

Updating the Progress Bar achieved in the New View

开发者_如何学PythonI want to Update the Progress bar in my application.

I have created a new view by making use of inflater and in that newly created view I want to show the Horizontal Progress Bar Updating.

How can I do that particularly?

Also I got to know that when We create a new view by Inflater, we need to add it to the Current Activity Class by addContentView(), I don't know how to do these though I have tried a lot till now.

Can anybody help me here?


So, as you don't provide code, let me search my crystal ball... wait... OK, there it is. You have something like this:

View someView = inflater.inflate(R.layout.view_with_progress_bar, null);

In order to access your ProgressBar, you have to use the findViewById method:

ProgressBar yourProgressBar = (ProgressBar)someView.findViewById(R.id.id_of_your_progress_bar);
// you can know modify the progress bar: yourProgressBar.setBlahBlah

In order to add the view that contains the progress bar to you current activity, you have to have a reference to the container that you previously set. So, I guess you previously did: setContentView(R.layout.something);, then you have a layout called something.xml; that layout contains a ViewGroup (LinearLayout, RelativeLayout, etc.; my crystal ball can't see that clearly). Then, you need to set an ID to that container, create a reference, and add your newly created view to it:

// in your onCreate method
setContentView(R.layout.something);

// let's suppose it's a LinearLayout
LinearLayout mainContainer = (LinearLayout)findViewById(R.id.id_you_gave_to_container);

// blha blah... the rest of your code. Keep in mind that you will
// probably have to declare the mainContainer outside the onCreate method

// here, you have already inflated your view, and want to add it to your activity
mainContainer.addView(someView);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜