Hello everyone,

first, I'm very sorry, if I'm in the wrong group for my question.
I have a Problem with my custom Listview. I created a Activity and an
appropriate xml-file with a ListView for the settings of my
application. Source Code comes below. Also I created a custom Layout
file for the rows, which contain a Textview and a Checkbox. The
settings it self are stored serialized in the filesystem and where
picked up, when the settings view is called. Perhaps thats not the
best Option, but that is not causing the problem i have.
In the List layout there is also a textview available as a header.
Now, when the settings are called, I just see the reader, the
remaining screen stays simply black. I tried to give the list another
background color, but the screen stays black.

Code from the Activity (onCreate method):
        public void onCreate(Bundle icicle)
        {
                userSettings = deserializeObject();

                if(userSettings.isEmpty())
                {
                        userSettings.add(new SettingItem("Camera",
android.os.Environment.DIRECTORY_DCIM, true));
                }
                super.onCreate(icicle);
                super.setContentView(R.layout.list);
                Context mContext = this.getApplicationContext();
                settingsList = (ListView)findViewById(R.id.settinglist);
                CustomSettingsAdapter setAdap = new 
CustomSettingsAdapter(mContext,
userSettings);
                settingsList.setAdapter(setAdap);

                settingsList.requestFocus();
                settingsList.requestFocusFromTouch();

Code from the CustomSettingsAdapter:
public View getView(int position, View convertView, ViewGroup parent)
{
          ViewHolder holder;
          if (convertView == null)
          {
                  convertView = mInflater.inflate(R.layout.settings_item, null);
                  holder = new ViewHolder();
                  holder.txtName = (TextView)
convertView.findViewById(R.id.setting_name);
                  holder.cb = (CheckBox) convertView.findViewById(R.id.check);

                  convertView.setTag(holder);
          }
          else
          {
                  holder = (ViewHolder) convertView.getTag();
          }

                
holder.txtName.setText(settingsArrayList.get(position).getName());
                
holder.cb.setChecked(settingsArrayList.get(position).getState());

                return convertView;
         }

XML-File of the list:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        xmlns:android="http://schemas.android.com/apk/res/android";>
        <TextView android:id="@+id/settings_list_title"
                android:layout_height="wrap_content"
                android:layout_width="fill_parent"
                android:text="@string/settings_header"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:gravity="center" />
        <ListView android:id="@+id/settinglist"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="#aaaaaa" />
        </LinearLayout>

XML-File of the rows:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
                xmlns:android="http://schemas.android.com/apk/res/android";
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:padding="4dp">
        <LinearLayout
                android:orientation="vertical"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="2dp">
                <TextView
                        android:id="@+id/setting_name"
                        android:textSize="18sp"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content">
                </TextView>
        </LinearLayout>
        <LinearLayout
                android:orientation="vertical"
                android:gravity="right"
                android:layout_gravity="right"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:padding="2dp">
                <CheckBox
                        android:id="@+id/check"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content">
                </CheckBox>
        </LinearLayout>


Thank you very much in advance for your help!
Greetings Tobi

-- 
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