Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.yaaic.deckster;
- import android.content.Context;
- import android.content.res.TypedArray;
- import android.util.Log;
- import android.view.LayoutInflater;
- import android.view.View;
- import android.view.ViewGroup;
- import android.widget.BaseAdapter;
- import android.widget.Gallery;
- import android.widget.TextView;
- public class DecksterAdapter extends BaseAdapter
- {
- private int width;
- private int height;
- public DecksterAdapter(int width, int height)
- {
- this.width = width;
- this.height = height;
- Log.d("foo", width + "x" + height);
- }
- public int getCount()
- {
- return 7;
- }
- public Object getItem(int position)
- {
- return position;
- }
- public long getItemId(int position)
- {
- return position;
- }
- private int[] colors = {
- 0xfffce94f,
- 0xfffcaf3e,
- 0xffe9b96e,
- 0xff8ae234,
- 0xff729fcf,
- 0xffad7fa8,
- 0xffef2929,
- };
- public View getView(int position, View convertView, ViewGroup parent)
- {
- LayoutInflater inflater = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- View v = inflater.inflate(R.layout.view, null);
- float fw = (float) width;
- float fh = (float) height;
- float vwf = fw / 100 * 80;
- float vhf = fh / 100 * 80;
- int w = (int) vwf;
- int h = (int) vhf;
- TextView tv = (TextView) v.findViewById(R.id.foo);
- tv.setTextColor(0xff000000);
- tv.setText("T" + position);
- tv.setBackgroundColor(colors[position]);
- v.setLayoutParams(new Gallery.LayoutParams(w, h));
- return v;
- }
- }
Add Comment
Please, Sign In to add comment