Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/main/java/nyc/c4q/ColorDrawable.java
Original file line number Diff line number Diff line change
@@ -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};


}

105 changes: 104 additions & 1 deletion src/main/java/nyc/c4q/ListViewActivity.java
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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<String> adapter = new ArrayAdapter<String>(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;
}
}
25 changes: 18 additions & 7 deletions src/main/res/layout/activity_listview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,31 @@

<LinearLayout
android:id="@+id/header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.0"
android:orientation="horizontal">

<TextView
android:id="@+id/textLog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fill this textview" />
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3.0"
android:text="@string/log" />

<EditText
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:id="@+id/adapterCount"
android:inputType="phone"/>

</LinearLayout>


<ListView
android:id="@+id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="9.0"/>
</LinearLayout>
5 changes: 5 additions & 0 deletions src/main/res/values/string.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="log">You have not clicked anything.</string>

</resources>