Leerer Dialog

Lucaaa

Bekanntes Mitglied
Hallo!
Wieso ist mein Dialog leer?

Java:
package com.ludevstudio.colorpicker;

import android.app.AlertDialog;
import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.text.Layout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.GridLayout;
import android.widget.GridView;


import java.util.ArrayList;


public class ColorpickerDialog extends AlertDialog {
    Colorpicker picker;

    public ColorpickerDialog(Context context, Colorpicker colorPicker) {
        super(context);
        this.picker = colorPicker;
        init();
    }

    private void init() {
    Adapter adapter =new Adapter(picker.getColors());
        LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
       View v = inflater.inflate(R.layout.color_picker_dialog, null);
        GridView grid = (GridView) v.findViewById(R.id.grid);
        grid.setAdapter(adapter);
    setView(v);
    }


    public class Adapter extends BaseAdapter {
        ArrayList<Integer> colors;
        ArrayList<Button> items;

        public Adapter(ArrayList<Integer> colors) {
            this.colors = colors;

        }
        @Override
        public int getCount() {
            return 0;
        }

        @Override
        public Object getItem(int i) {
            return null;
        }

        @Override
        public long getItemId(int i) {
            return 0;
        }

        @Override
        public android.view.View getView(int i, android.view.View view, ViewGroup viewGroup) {
            Button b =new Button(getContext());
            b.setBackgroundColor(colors.get(i));

            return b;
        }
    }
}

XML:
<?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">


    <GridView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/grid"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="10dp"
        android:verticalSpacing="10dp"

        android:horizontalSpacing="10dp"
        android:numColumns="3"
        android:columnWidth="60dp"
        android:stretchMode="columnWidth"

        android:gravity="center"
        />

</LinearLayout>
 

Ähnliche Java Themen

Neue Themen


Oben