Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is it possible to set adapter to linear layout?

Is it possible to set adapter to a LinearLayout?

I don't want to use ListView since I am using ScrollView. so I am using LinearLayout...

In that I am dynamically adding views and now I need to use adapter.. so anybody have any suggestions?

I am doing this...

LinearLayout clientList = (LinearLayout) findViewById(R.id.clients); adapter = new Sample1AdapterActivity(this, arrayList); View list = (ListView) getLayoutInflater().inflate(R.layout.user_details, getListView(), false); 
like image 477
shashi2459 Avatar asked Jul 23 '14 08:07

shashi2459


People also ask

How do you create a linear layout?

To create a linear layout in which each child uses the same amount of space on the screen, set the android:layout_height of each view to "0dp" (for a vertical layout) or the android:layout_width of each view to "0dp" (for a horizontal layout). Then set the android:layout_weight of each view to "1" .

Can we use linear layout inside RelativeLayout?

We can use LinearLayout inside RelativeLayout. We can also use RelativeLayout as a Child of LinearLayout.

Is linear layout better than constraint layout?

So at the rendering, it doesn't have to calculate a lot just render with one onMeasure() method call. That is why the linear layout is more efficient in terms of performance.

Can we use constraint layout inside linear layout?

Most of what can be done in LinearLayout and RelativeLayout can now be done with a new layout system called ConstraintLayout. It's important to note the class hierarchy of these View Layouts.


1 Answers

no you can't. What you can do is inflate the single row, and adding to the LinearLayout. In pseudo code:

  LinearLayout linearLayout = (LinearLayout) findViewById(...);   LayoutInflater inflater = LayoutInflater.from(this);   for (item in arrayList) {      View view  = inflater.inflate(R.layout.row, linearLayout, false);       // set item content in view      linearLayout.addView(view)   } 
like image 61
Blackbelt Avatar answered Sep 28 '22 22:09

Blackbelt