如何从Android中的单个ListView项获取四个输入值?

时间:2022-11-27 14:27:30

I have a ListView which of it's items contains four different input values. My task is when I click any of the item it has to take the input values and store it in four different variables.

我有一个ListView,其中的项目包含四个不同的输入值。我的任务是当我单击它所具有的任何项目时获取输入值并将其存储在四个不同的变量中。

The list view items were in following format:

列表视图项的格式如下:

!+11.3326,+077.7193,08:41!+11.3326,+077.7194,08:41#

1 个解决方案

#1


Just by blind guess, suppose you have ListView listView and ArrayList<String> items which represent your data, then, you go like this :

只是盲目猜测,假设您有ListView listView和ArrayList 项代表您的数据,那么,你会这样:

        listView.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {
                String[] values = items.get(position).split("+") // your separator here, i gues it is "+";
                //Do with your values whatever you want
            }
        });

#1


Just by blind guess, suppose you have ListView listView and ArrayList<String> items which represent your data, then, you go like this :

只是盲目猜测,假设您有ListView listView和ArrayList 项代表您的数据,那么,你会这样:

        listView.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {
                String[] values = items.get(position).split("+") // your separator here, i gues it is "+";
                //Do with your values whatever you want
            }
        });