diff --git a/src/main/java/nyc/c4q/ColorDrawable.java b/src/main/java/nyc/c4q/ColorDrawable.java new file mode 100644 index 0000000..3d7f7af --- /dev/null +++ b/src/main/java/nyc/c4q/ColorDrawable.java @@ -0,0 +1,25 @@ +package nyc.c4q; + +import android.graphics.Color; + +/** + * Created by charlynbuchanan on 7/6/15. + */ +public class ColorDrawable { + + int one = Color.parseColor("#142b44"); + int two = Color.parseColor("#1d508d"); + int three = Color.parseColor("#297cbb"); + int four = Color.parseColor("#288ad6"); + int five = Color.parseColor("#0fdebd"); + int six = Color.parseColor("#16c98d"); + int seven = Color.parseColor("#feef6d"); + int eight = Color.parseColor("#ffc83f"); + int nine = Color.parseColor("#fa5e5b"); + int ten = Color.parseColor("#bf538d"); + + public int [] colours = {one, two, three, four, five, six, seven, eight, nine, ten}; + + +} + diff --git a/src/main/java/nyc/c4q/ListViewActivity.java b/src/main/java/nyc/c4q/ListViewActivity.java index 78104c6..d4507d8 100644 --- a/src/main/java/nyc/c4q/ListViewActivity.java +++ b/src/main/java/nyc/c4q/ListViewActivity.java @@ -1,10 +1,17 @@ package nyc.c4q; import android.app.Activity; +import android.database.DataSetObserver; import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.ListAdapter; +import android.widget.ListView; import android.widget.TextView; -public class ListViewActivity extends Activity { +public class ListViewActivity extends Activity implements ListAdapter { public static final String[] COLORS = { "#142b44", @@ -19,11 +26,107 @@ public class ListViewActivity extends Activity { "#bf538d" }; public TextView textLog; + int count = COLORS.length; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_listview); textLog = (TextView) findViewById(R.id.textLog); + String[] COLORS = { + "#142b44", + "#1d508d", + "#297cbb", + "#288ad6", + "#0fdebd", + "#16c98d", + "#feef6d", + "#ffc83f", + "#fa5e5b", + "#bf538d" + }; + if (getCount() != count){ + Log.e("something's wrong", "fix the count"); + } + + //Get list from xml + ListView list = (ListView)findViewById(R.id.list); + ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, COLORS ); + ColorDrawable colorDrawable = new ColorDrawable(); + list.setAdapter(adapter); + for (int i = 0; i < ListViewActivity.COLORS.length; i++) { + View v = adapter.getView(i, null, list); +// for (int n = 0; n < colorDrawable.colours.length; n++) { +// v.setBackgroundColor(n); +// } + if (i == 0){ + View viewZero =getView(0, v, list); + viewZero.setBackgroundColor(colorDrawable.one); + } + } + + } + + @Override + public boolean areAllItemsEnabled() { + return false; + } + + @Override + public boolean isEnabled(int position) { + return false; + } + + @Override + public void registerDataSetObserver(DataSetObserver observer) { + + } + + @Override + public void unregisterDataSetObserver(DataSetObserver observer) { + + } + + @Override + public int getCount() { + return 0; + } + + @Override + public Object getItem(int position) { + return null; + } + + @Override + public long getItemId(int position) { + return 0; + } + + @Override + public boolean hasStableIds() { + return false; + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + + + + return null; + } + + @Override + public int getItemViewType(int position) { + return 0; + } + + @Override + public int getViewTypeCount() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; } } diff --git a/src/main/res/layout/activity_listview.xml b/src/main/res/layout/activity_listview.xml index 0d4b9d6..d0e9f2c 100644 --- a/src/main/res/layout/activity_listview.xml +++ b/src/main/res/layout/activity_listview.xml @@ -9,20 +9,31 @@ + android:layout_width="0dp" + android:layout_height="match_parent" + android:layout_weight="3.0" + android:text="@string/log" /> + + + + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="9.0"/> \ No newline at end of file diff --git a/src/main/res/values/string.xml b/src/main/res/values/string.xml new file mode 100644 index 0000000..3101929 --- /dev/null +++ b/src/main/res/values/string.xml @@ -0,0 +1,5 @@ + + + You have not clicked anything. + + \ No newline at end of file