开发者

Is it possible to add an inderminate progressbar within a TableLayout?

I have a scroll view that contains Tablelayout as its Child view. Now while I am receving the data from the server I'd like to display a progress bar on the screen. When the data is received the p开发者_StackOverflow中文版rogress bar must replaced by the tablerows.

I am able to achieve this partially. I add a progressbar view into the 3rd row (row 1 and 2 are headers) which has visibility gone once the data is received and tablerows are created.

The issue is that the progress bar appears at the top of the screen. To be consistent with the app, the progress bar must be in the middle of the screen as I have it on ListViews.

Here is the code snippet for Progressbar

`<TableRow
android:layout_width="wrap_content" android:layout_height="wrap_content"     android:gravity="center_horizontal">
<ProgressBar
android:id="@+id/list_progressbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>   
</TableRow>


Have a TableLayout inside that put all TableRows as I hope you doing, including the one with the ProgressBar, now instead of going to replace.

You can achieve it other way, just make the View.GONE of the TableRow containing ProgressBar, and View.VISIBLE of TableRow which you want to show.

For example;

<TableLayout>
 <TableRow android:id="@+id/trheader1" .../>
 <TableRow android:id="@+id/trheader2" .../>
 <!-- keeping the visibility of gone //-->
 <TableRow android:id="@+id/trRow3" android:visibility="gone" .../>
 <!-- tr containing progressBar //-->
 <TableRow android:id="@+id/trprogressBar" .../>
</TableLayout>

as you recieve the data

((TableRow) findViewById(R.id.trRow3)).setVisibilty(View.VISIBLE);
((TableRow) findViewById(R.id.trprogressBar)).setVisibilty(View.GONE);

So, I hope this will work for you. Thanks!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜