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);
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" .
We can use LinearLayout inside RelativeLayout. We can also use RelativeLayout as a Child of LinearLayout.
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.
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.
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) }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With