【问题标题】:android listview not showing new added items.if i do keyboard off or on with back key list refreshedandroid listview没有显示新添加的项目。如果我关闭或打开键盘并刷新后退键列表
【发布时间】:2014-08-25 12:16:30
【问题描述】:

当我在 android 列表上使用返回键隐藏键盘时,它可以正常工作并且我添加了新项目。我想刷新列表而不使用返回键隐藏键盘。 我的代码是:

lv=(ListView) findViewById(R.id.listView1);
strArr=new ArrayList<String>();
adapter = new CustomListAdapter(getApplicationContext() , R.layout.custom_list , strArr);

lv.setAdapter(adapter);

while( ( line = br.readLine() ) != null ){
    strArr.add(line);
}

adapter.notifyDataSetChanged();

【问题讨论】:

标签: android listview lis


【解决方案1】:

在单击返回按钮之前,您会陷入循环。试试:

while( ( line = br.readLine() ) != null ){
   strArr.add(line);
   adapter.notifyDataSetChanged();
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-08-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多