0

So I want to create a counter app that has a layout similar like it is in the photo below.

I would like to have 3 items in each line and pressing "add new" should add a new line.

Should I use ListView or maybe GridLayout?

I know how to create a ListView with just a text in it, but have no idea how to do this.

Thanks.

https://i.sstatic.net/0Nedi.png

1
  • What research have you done to try to find out to make an adapter with more than just text? Commented Aug 17, 2017 at 13:24

2 Answers 2

1

You can use ListView with custom ArrayAdapter. You can go through the example here ListView

The best option is to use RecyclerView. Go to the documentation here RecyclerView .

You can find tons of examples of using RecyclerView online. And from the layout of your image it looks like you need nested layout.

Sign up to request clarification or add additional context in comments.

Comments

0

You should use recyclerview for the same. When you click add Button ::

        mAdapter.addItem();
        mRecycler.scrollToPosition(mAdapter.getItemCount() - 1);

Put this add method in Adapter. What Notify does is, tells the adapter that list has been updated which contains that data model, and so new view is created corresponding to that model.

public void addItem() {

// this is a dummy object. mDetails is the list of items.

    ItemDetails item = new ItemDetails();
    item.setItem("");
    item.setPrice("");
    item.setQty("");
    mDetail.add(item);
    notifyItemInserted(mDetail.size() - 1);
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.