1

So I started learning Android programming recently and was wondering if there another way to implement gson data using retrofit besides using an adapter and a list.

So basically I have to make a full-screen activity with a few TextViews and ImageViews (so I don't need a list). Do I have to make an adapter and a ListView for something as simple as that or is that the best way?

André Sousa
  • 1,692
  • 1
  • 12
  • 23
aratata
  • 1,147
  • 1
  • 6
  • 22

2 Answers2

3

Do I have to make an adapter and a ListView for something as simple as that

No. You use adapter-based widgets (typically RecyclerView right now) when:

  • The JSON is dominated by an array, and
  • You do not know up front the size of that array

If, instead, your JSON is a simple object, with a well-defined structure known at compile time, you are welcome to use that object to populate simple widgets in a simple layout.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
0

If you don't want to use ListView and RecyclerView then you can use LayoutInflator to have some of your limited Views Inflated to the LinearLayout or some other Layout.

Note: But for that views to get selected and do some operations or to apply animations will be vary difficult for you.

Check here about LayoutInflator here:

https://developer.android.com/reference/android/view/LayoutInflater

and here:

What does LayoutInflater class do? (in Android)

Muhammad waris
  • 314
  • 1
  • 10