【问题标题】:How can I add a row from within the application ? Android studio如何从应用程序中添加一行?安卓工作室
【发布时间】:2021-02-27 05:21:34
【问题描述】:

大家好,我需要你的帮助

我正在做一个购物应用 用户输入条形码,程序输入产品名称和价格

Here is a picture of the table

但我不知道该怎么做。 我使用了“表格布局” 我添加了 14 个“tableRow” 这是我的代码

code=findViewById(R.id.barcode);
code.addTextChangedListener(enter);
    }
    private TextWatcher enter = new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {

            if(code.getText().toString().trim().equals("659245631")) {
                //what can i write here to add row like this
                // (coulmn0,coulmn1)
                // ( price ,  product name)
            }
        }
        @Override
        public void afterTextChanged(Editable s) {
            if(code.getText().toString().trim().equals("659245631"))
            {


            }

        }
    };

但我不知道需要采取什么措施你能帮帮我吗?

【问题讨论】:

  • 我真的需要帮助:(

标签: java android android-studio if-statement tablelayout


【解决方案1】:

您可以将TableRow 替换为ListViewRecycleView,并根据您的条形码进行过滤。

Here 是一个关于如何创建 ListView 的简单示例

Here 是一个关于如何在 listView 中进行过滤的示例。

【讨论】:

  • 谢谢,我已将 Table Row 与 RecyclerView 相关联,但我无法设置条件。您知道我该怎么做吗?
  • 我的想法是用 RecycleView 或 ListView 完全替换 TableRows
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-05
  • 2018-01-29
  • 2017-02-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多