【问题标题】:Change a TextView value in a custom ListView更改自定义 ListView 中的 TextView 值
【发布时间】:2012-03-25 08:36:57
【问题描述】:

【问题讨论】:

    标签: android listview android-listview listadapter


    【解决方案1】:

    onItemClick()方法中获取点击行的位置(位置参数)对应的PhoneBook元素,更新值,然后通过调用@987654323方法通知适配器数据发生了变化@:

    list.setOnItemClickListener(new OnItemClickListener() {
    
                @Override
                public void onItemClick(AdapterView<?> arg0, View view, int position, long index) {
                    // make the adapter a field in your class (or final)
                    PhoneBook element = (PhoneBook) adapter.getItem(position);
                    //modify the PhoneBook element
                    element.setPhone("555-555-555");
                    // notify the adapter that something has changed
                    adapter.notifyDataSetChanged();
                    showToast(listOfPhonebook.get(position).getName());
                }
            });
    

    【讨论】:

    • 我尝试了很多例子,这对我有用!很棒的工作
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-08
    • 2019-02-24
    • 1970-01-01
    相关资源
    最近更新 更多