简体   繁体   中英

add data from edittext to listview in android

I have an add button, a textbox called edittext, and a listview. When I click the add button data currently in edittext should move to list view. How can I make this happen?

"edittext should move to list view".. do you mean focus to be moved to listview OR Editext must disappear and listview must appear?

To handle focus you could use setFocusable() http://developer.android.com/guide/topics/ui/ui-events.html#HandlingFocus

For second option, you could hide widgets in event handlers.

@GSree it is very clear that user569553 wants that when he/she clicks on add button tha data of edittext feild should move to list.

so simply get data using getText() method and the go through this link.

best explanation i have ever found about implementation of getView() and listview.

http://android.amberfog.com/?p=296

如果使用的是内置列表适配器(例如ArrayAdapter或SimpleAdapter),则只需将EditText.getText()中的数据添加到数据集合中,创建一个新的列表适配器,然后在调用setListAdapter()时列表视图将刷新,并添加您的新项目。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM