ListView 和不确定的 ProgressBar

发布于 2024-08-31 17:29:19 字数 651 浏览 4 评论 0原文

抱歉,这个问题可能听起来很愚蠢,

但是:如何根据您刚刚单击的单元格激活进度栏?

我有一个列表视图,长按后会显示一个菜单。

当我单击我的选项之一时,我想根据我单击的单元格在列表视图中显示进度栏。目前,无论我在做什么,它总是显示我的第一个单元格,

public boolean onContextItemSelected(MenuItem item) {
     AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();

     switch (item.getOrder()) {
        case 0:
                    mProgressBar = (ProgressBar)findViewById(R.id.welcome_progressbar);
                    mProgressBar.setVisibility(View.VISIBLE);
            ... some execution ....

                    return true;
        case 1:
                     ...

有人发现有什么问题吗?

Sorry for the question it might sounds stupid,

But: how do you activate a ProgressBar according to the cell you just cliked on ?

I have a list view, with a menu that shows after a long press.

When I click on one of my option I would like to display the ProgressBar in the listView according to the cell I clicked on. It is currently always displaying the one of my first cell, whatever I am doing

public boolean onContextItemSelected(MenuItem item) {
     AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();

     switch (item.getOrder()) {
        case 0:
                    mProgressBar = (ProgressBar)findViewById(R.id.welcome_progressbar);
                    mProgressBar.setVisibility(View.VISIBLE);
            ... some execution ....

                    return true;
        case 1:
                     ...

Does anyone see anything wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

咽泪装欢 2024-09-07 17:29:19

这是因为 findViewById 找到列表中视图的第一个实例。
您需要通过适配器中 getView 中的项目状态来处理该问题。您可以尝试使用选中/按下等状态,或者只是为您的项目设置一个布尔值,在 getView 中检查它,并根据该状态显示/隐藏进度。

That's because findViewById finds first instance of the View in the list.
You need to handle that through your item states in your getView in the adapter. You can try to use states like selected/pressed or just set a boolean to your item, check it in getView, and show/hide progress based on that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文