Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Dynamically adding ListViewItem to Listview

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 402
    Comment on it

    To dynammically add new elements into listview we need a Edittext(etAddItem) to input the item/element, a Button(btnAdd) for adding item to the list, and a listview which shows elements in a vertical scrolling manner.

            etAddItem = (EditText)findViewById(;
            btnAdd = (Button)findViewById(;
            listView = (ListView)findViewById(;

    btnAdd(Button) onClickListner, when user clicks on add button element/item is added to the arraylist.

     btnAdd.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {

    finally, adapter works as a communication channel between Listview and ArrayList.

    arrayList = new ArrayList();
    adapter = new ArrayAdapter(getApplicationContext(), android.R.layout.simple_spinner_item, arrayList);
    // Here, you set the data in your ListView

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: