Hello!
I try to populate a Gallery dynamically with some values put it in
TextViews.
I cannot manage to do that. The code is quite complex.
In main java class i get the Gallery and i set it to a custom adapter.
   this.galleryView.setAdapter(new
GalleryAdapter(getApplicationContext(), values));
where values is a ArrayList<String> with names to be put in TextViews
in Gallery.
In GalleryAdapter i have something like this
public View getView(int position, View view, ViewGroup parent) {
                View v = null;

                if (view == null) {
                        v =
LayoutInflater.from(this.context).inflate(R.layout.gallery_item,
parent, false);
                } else {
                        v = view;
                }

                LinearLayout galleryLinearLayout = (LinearLayout)
v.findViewById(R.id.galleryItemLinearLayout);
                for (String val : this.values) {
                        TextView textview = new TextView(this.context);
                        textview.setText(val);
                        textview.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
                        textview.setPadding(30, 5, 30, 5);
                        textview.setTextColor(Color.WHITE);
                        galleryLinearLayout.addView(textview);
                }
                return v;
        }

and gallery_item xml file is like this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android";
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent">
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/galleryItemLinearLayout">
    </LinearLayout>
</LinearLayout>
The behavior is not the expected one. Is not displays all values and
also the scroll acts strange
Can someone tell me what i do wrong or the guide me to a better
example.
Thanks

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to