I have a data-structure which is of type:
ArrayList<ArrayList<String>>;
...It contains a set of elements of a news feed; each element is itself a list of fields and each field is a tuple(key:value) where both key&value are of type String.
NOTE: the reason fields are stored in ArrayList is I don't always know how many the feed-parser will spurt out.
The view:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:id="#+id/news"
android:text="#string/news_and_events"
android:layout_row="6"
android:layout_column="4"
android:layout_columnSpan="3"
android:layout_rowSpan="3"
android:width="180dp"
android:height="245dp"
android:layout_marginBottom="10dp">
<!--FEED-->
<ListView
android:id="#android:id/list"
android:layout_height="match_parent"
android:layout_width="match_parent"
/>
</RelativeLayout>
The row-template I want to use is:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<ImageView
android:id="#+id/picture"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_marginRight="6dip"
android:contentDescription=""
/>
<!--STARTING WITH title-->
<TextView
android:id="#+id/title"
android:layout_width="fill_parent"
android:layout_height="26dip"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_toRightOf="#id/picture"
android:ellipsize="marquee"
android:singleLine="true"
android:text=""
android:textSize="20sp"
/>
<TextView
android:id="#+id/body"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true" />
</RelativeLayout>
As you can see there are 3-fields: title, body, image (a news feed).
So I'm completely stumped as to what type of adapter I should use.
All the ones' I've looked at don't seem to match what I want to do; specifically because of the data-structure I'm using.
Perhaps I should use a cursor adapter?
If so, how would I map this into a Relational-database?!
I think you should try using a BaseAdapter, it's the most flexible adapter Android has(I think)...
By doing so, you can implement a custom Adapter, which goes thru the ArrayList(using 2 cycles for extracting) and then parsing it to the visual components you specified.
Since it's constructor receives the context, the view and the data, you'll have the ImageView and so, there.
Related
Here's my layout screenshot:
How can I arrange all these TextView for them to have a good format (heading being Taking responsibility (means being aware)..) alignment etc.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Menu"
android:background="#android:color/holo_blue_bright"
>
<TextView
android:text="*Follow safety guide for moving around the town and between towns."
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView25"
android:gravity="left"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="51dp" />
<TextView
android:text="*Avoid crowds and do not participate actively in demonstrations even when it is related to programme work."
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView25"
android:gravity="left"
android:layout_below="#+id/textView25"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="15dp" />
<TextView
android:text="*Avoid crowds and do not participate actively in demonstrations even when it is related to programme work."
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView25"
android:gravity="left"
android:layout_marginBottom="23dp"
android:layout_above="#+id/textView25"
android:layout_toRightOf="#+id/textView25"
android:layout_toEndOf="#+id/textView25" />
<TextView
android:text="*keep this briefing pack in an accessible place, and the emergency numbers in your mobile phone memory"
android:layout_width="wrap_content"
android:gravity="bottom"
android:layout_height="wrap_content"
android:id="#+id/textView28"
android:layout_above="#+id/textView25"
android:layout_toRightOf="#+id/textView25"
android:layout_toEndOf="#+id/textView25"
android:layout_marginBottom="46dp" />
<TextView
android:gravity="center"
android:textColor="#000"
android:textSize="15dp"
android:text="Taking resposibility(means being aware)"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView22"
android:layout_marginTop="18dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:text="*Avoid moving around town by yourself and always make others aware of your location."
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:id="#+id/textView25"
android:layout_marginTop="76dp"
android:layout_below="#+id/textView22"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:text="*Share any security information that might have implications for Ballloon Ventures to the Country Manager or pc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView24"
android:gravity="left"
android:layout_below="#+id/textView26"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="30dp" />
<TextView
android:text="*If using host home accommondation,check that it is secure.if it is not,tell the Programme Coordinator"
android:layout_width="wrap_content"
android:gravity="bottom"
android:layout_height="wrap_content"
android:id="#+id/textView28"
android:layout_marginTop="14dp"
android:layout_below="#+id/textView24"
android:layout_alignRight="#+id/textView25"
android:layout_alignEnd="#+id/textView25" />
<TextView
android:text="*Report all incidents to your Programmer Cordinator."
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView26"
android:gravity="left"
android:layout_below="#+id/textView25"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="55dp" />
</RelativeLayout>
Because if I drag one TextView it affecting all other TextView.
As #GabeSechan said, you need to learn what android:layout_xxx properties in RelativeLayout means.
When you moving a View in RelativeLayout via Layout Editor, you need to consider some of the following properties in your layout:
android:layout_above="#+id/textView25"
android:layout_below="#+id/textView24"
android:layout_toRightOf="#+id/textView25"
android:layout_toEndOf="#+id/textView25"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_above="#+id/textView25" means that you want the View above textView25 view.
android:layout_below="#+id/textView24" means that you want the View below textView25 View.
The following properties means that you want the view to the right side of TextView25 View:
android:layout_toRightOf="#+id/textView25"
android:layout_toEndOf="#+id/textView25"
The following properties means that you want the view to align with the left side of the parent layout:
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
If you want to edit views position in a RelativeLayout, please don't depends with drag and drop via Layout Editor. You better do it manually except you want to have a headache later. Use Layout Editor to view the design result.
Design with a paper or imagination first, then code it after that.
Try to learn it from:
Relative Layout
Constructing View Layouts
The best practice for doing that would be to open a splitview between your code and design views and then editing the code to place the text in the correct location, using attributes such as padding, margin, aligning, below, above, etc. refer to this guide for positioning stuff in relative layout and combine it with other formatting attributes such as margin and padding.
The app requires a scrollable list of chords (i.e. "Em7", "C#", etc.) and I'm not sure the best way to get them into the ScrollView. I can generate a list easily in code (there are about 2500 items...), so it boils down to whether I need all the overhead of a 'Large Text' widget, or can I just have clickable text in the list? This ScrollView is on an Activity with some text fields and two other ScrollViews that have lists of chord modifiers.
Here's what I have so far:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="#string/new_song_name"
android:id="#+id/textView3"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText"
android:layout_alignTop="#+id/textView3"
android:layout_toRightOf="#+id/textView3"
android:layout_toEndOf="#+id/textView3"
android:layout_marginLeft="29dp"
android:layout_marginStart="29dp"
android:width="400dp"
style="#style/Base.Widget.AppCompat.EditText"
android:textStyle="bold"/>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="100dp"
android:layout_height="400dp">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
</LinearLayout>
</ScrollView>
<android.support.v7widget.GridLayout
android:layout_width="match_parent"
android:layout_height="400dp"
android:layout_marginTop="63dp"
android:layout_below="#+id/editText"
android:layout_toLeftOf="#+id/editText"
android:layout_toStartOf="#+id/editText"
android:id="#+id/view">
</android.support.v7widget.GridLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
***android:text="C"***
//the line above is representative of the list items.
android:id="#+id/textView4"
android:layout_alignTop="#+id/view"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="40dp"/>
</RelativeLayout>
use fragment, this link can help you :
https://developer.android.com/guide/components/fragments.html
https://developer.android.com/training/basics/fragments/
Dude, why you don't use ListView and ListAdapter ?
and load ChordList from datebase;
So it will be scrolled.
ArrayList<String> chords = new ArrayList<>();
chords = getFromDb;
ListView chordList = (ListView) findViewById(R.id.list_item);
chordList.setAdapter(new ArrayAdapter<String>(getApplicationContext(),
android.R.layout.simple_list_item_1, chords ));`
`
I am trying to access a button from a specific view. The same view is displayed 6 times. This is the code I am using.
public void testTimeConfig(){
onData(withDesc("description")).onChildView(withId(R.id.positive)).perform(click());
}
private static Matcher<Object> withDesc(String desc) {
return allOf(is(instanceOf(String.class)), is(desc));
}
When I run, I get an error:
Error performing 'load adapter data' on view 'is assignable from class: class android.widget.AdapterView'.
Is this the best way to access a child view? If so, how?
EDIT
This is the code I am trying to use now.
onView(allOf((withContentDescription("description")), hasSibling(withContentDescription("SettingsLayout")), hasSibling(withId(R.id.positive)))).perform(click());
and
onView(allOf((withContentDescription("description")), hasSibling(withId(R.id.positive)))).perform(click());
With this Error:
No views in hierarchy found matching
The xml
<view
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/setAGoalTitle"
android:layout_alignParentLeft="true"
class="com.xxx"
android:layout_marginTop="30dp"
android:id="#+id/timeGoalWidget"
app:goalLabel="#string/time_min_upper"
app:icon="#drawable/ic_icn_summary_time"
app:step="300"
app:valueFormat="time"
android:gravity="center_horizontal"
android:layout_marginBottom="60dp"
android:contentDescription="setAGoalTimeConfigurator"/>
<view
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="#id/timeGoalWidget"
class="com.xxx"
android:id="#+id/distanceGoalWidget"
app:goalLabel="#string/distance_upper"
app:icon="#drawable/ic_icn_summary_track"
app:step="0.25"
app:valueFormat="decimal_two"
android:gravity="center_horizontal"
android:contentDescription="setAGoalDistanceConfigurator"/>
<view
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/timeGoalWidget"
android:layout_alignLeft="#id/timeGoalWidget"
class="com.xxx"
android:id="#+id/paceGoalWidget"
app:goalLabel="#string/pace_upper"
app:icon="#drawable/ic_icn_summary_pace"
app:valueFormat="time"
app:step="10"
android:gravity="center_horizontal"
android:layout_marginBottom="60dp"
android:contentDescription="setAGoalPaceConfigurator"/>
<view
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#id/distanceGoalWidget"
android:layout_alignTop="#id/paceGoalWidget"
class="com.xxx"
android:id="#+id/speedGoalWidget"
app:goalLabel="#string/speed_upper"
app:icon="#drawable/ic_icn_summary_speed"
app:step="0.5"
app:valueFormat="decimal_two"
android:gravity="center_horizontal"
android:contentDescription="setAGoalSpeedConfigurator"/>
<view
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/paceGoalWidget"
android:layout_alignLeft="#id/paceGoalWidget"
class="com.xxx"
android:id="#+id/inclineGoalWidget"
app:goalLabel="#string/incline_percent_upper"
app:icon="#drawable/ic_icn_summary_elevation"
app:step="0.5"
app:valueFormat="decimal_two"
android:gravity="center_horizontal"
android:contentDescription="setAGoalInclineConfigurator"/>
<view
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#id/speedGoalWidget"
android:layout_alignTop="#id/inclineGoalWidget"
class="com.xxx"
android:id="#+id/caloriesGoalWidget"
app:goalLabel="#string/calories_upper"
app:icon="#drawable/ic_icn_summary_calories"
app:step="10"
app:valueFormat="decimal_zero"
android:gravity="center_horizontal"
android:contentDescription="setAGoalCaloriesConfigurator"/>
</RelativeLayout>
The view xml that is used 6 times.
<ImageButton
android:id="#+id/increaseGoalButton"
android:layout_height="#dimen/view_goal_setting_incrementor_button_height_width"
android:layout_width="#dimen/view_goal_setting_incrementor_button_height_width"
android:background="#drawable/button_goal_widget"
android:gravity="center"
android:src="#drawable/ic_plus"
android:textSize="#dimen/view_goal_setting_incrementor_button_text_size"
android:textColor="#color/goal_configuration_widget_button_text_color"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="1dp"
android:contentDescription="#string/increase"/>
<ImageButton
android:id="#+id/decreaseGoalButton"
android:layout_height="#dimen/view_goal_setting_incrementor_button_height_width"
android:layout_width="#dimen/view_goal_setting_incrementor_button_height_width"
android:background="#drawable/button_goal_widget"
android:gravity="center"
android:src="#drawable/ic_minus"
android:textSize="#dimen/view_goal_setting_incrementor_button_text_size"
android:layout_alignParentRight="true"
android:textColor="#color/goal_configuration_widget_button_text_color"
android:layout_below="#id/increaseGoalButton"
android:contentDescription="#string/decrease"/>
<LinearLayout
android:id="#+id/goalWidgetValueContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_toLeftOf="#id/increaseGoalButton"
android:layout_centerVertical="true"
android:gravity="center_vertical|right"
android:layout_marginRight="#dimen/view_goal_setting_value_margin_right" >
<TextView
android:id="#+id/goalValueTextView"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textColor="#color/goal_configuration_widget_value_text_color"
android:textSize="#dimen/view_goal_setting_value_text_size"
android:lineSpacingExtra="-10sp"
app:typeface="proxima_bold"
android:text="999:00"/>
<TextView
android:id="#+id/goalValueLabelTextView"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="right"
android:textSize="#dimen/view_goal_setting_value_label_text_size"
android:textColor="#color/goal_configuration_widget_value_text_color"
android:includeFontPadding="false"
android:lineSpacingExtra="10sp"
android:text="#string/incline_percent_upper"/>
</LinearLayout>
It is the ImageView with id increaseGoalButton that I am trying to click.
Based on your last comment you should use onView() instead of onData().
I think you'll be able to click the button using hasSibling() - example
onView(allOf(withId(R.id.positive), hasSibling(withDesc(someString))))
.perform(click());
or examples without your custom matcher (sibling view has text):
onView(allOf(withId(R.id.positive), hasSibling(withText(someString))))
.perform(click());
or (sibling view has content description):
onView(allOf(withId(R.id.positive), hasSibling(withContentDescription(someString))))
.perform(click());
EDITED:
OK, I'd try these two variants:
onView(allOf(withId(R.id.increaseGoalButton), isDescendantOfA(withId(R.id.timeGoalWidget))))
.perform(click());
or
onView(allOf(withId(R.id.increaseGoalButton), withParent(withId(R.id.timeGoalWidget))))
.perform(click());
None of your content descriptions match the string "description" that's why it doesn't find anything.
Assuming the button id is R.id.positive, and the id is unique in the current activity view, you can simply use:
onView(withId(R.id.positive)).perform(click());
I am using a Relative Layout(RL) to Hold a List View(lv) and a few bunch of other widgets like Text View(tv), Edit Text(et), then a few Buttons(btn) and finally one Progress Bar(pb).
Scenarios
1. When i add child Views to the Parent Container View viz. Relative Layout(rl), in the order: RL(Btn1->Btn2->tv1->tv2->LV->pb). Then we have no problem, i mean No Exception, No Problem.
2. But when i do the ordering change like RL(tv1->tv2->LV->Btn1->Btn2->pb). then i am getting a classcast Exception.
Note: the two buttons should be over the listview, as both of them are social website buttons, i mean Facebook and Twitter.
XML Code:
<RelativeLayout
android:id="#+id/rlfornews"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dip"
android:layout_marginTop="5dip"
android:background="#drawable/newsbg"
android:orientation="vertical"
android:paddingBottom="5dip" >
<Button
android:id="#+id/btnbasetw"
android:layout_width="30dip"
android:layout_height="30dip"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginBottom="10dip"
android:layout_marginLeft="5dip"
android:layout_marginRight="10dip"
android:background="#drawable/twitter_icon"
android:visibility="gone" />
<Button
android:id="#+id/btnbasefb"
android:layout_width="30dip"
android:layout_height="30dip"
android:layout_centerVertical="true"
android:layout_marginBottom="10dip"
android:layout_toLeftOf="#id/btnbasetw"
android:background="#drawable/facebook_icon"
android:visibility="gone" />
<TextView
android:id="#+id/tvnewscon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dip"
android:background="#drawable/newstitle"
android:gravity="center_vertical"
android:paddingLeft="8dip"
android:shadowColor="#color/black"
android:shadowDy="1"
android:shadowRadius="1"
android:text="#string/news"
android:textColor="#color/white" />
<TextView
android:id="#+id/tvfornews"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/tvnewscon"
android:layout_marginTop="10dip"
android:gravity="center"
android:text="#string/no_data_found"
android:visibility="gone" />
<ListView
android:id="#+id/lvdashboardnews"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#id/tvnewscon"
android:padding="4dip"
android:visibility="visible" >
</ListView>
<ProgressBar
android:id="#+id/pbfornews"
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
Note: The Progress Bar might be below, but it is just to user information, that some data is loading. and when i get that data, i am making its Visibility to VIEW.GONE state, and the List View being already there !
My question is when i follow the First Scenario, even though i have a Progress Bar from the entire time, i am not getting a Class Cast Exception. But i am getting the exception, when i change to Scenario 2. So why i am i getting it?
I am not sure about these but may be the reason is you have used the android:layout_below = "#id/textview" instead of use these android:layout_below = "#+id/textview" all UI.
If you can do these UI using the LinearLayout.
I have a custom ListActivity in which i have a custom ListAdapter that inflates a layout for each item in the list. In eclipse, in the visual editor the layout looks like this
This is made by the following code:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/largeFrame"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="#+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="1dp"
android:layout_marginRight="3dp"
android:layout_marginTop="5dp"
android:background="#color/mainBack"
android:orientation="vertical" >
<View
android:id="#+id/imageView1"
android:layout_width="5dp"
android:layout_height="fill_parent"
android:layout_alignParentLeft="false"
android:layout_alignParentTop="false"
android:layout_marginLeft="2dp"
android:background="#android:color/darker_gray" />
<TextView
android:id="#+id/newtimeslot_class"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="4dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/imageView1"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/black" />
<View
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_alignRight="#+id/newtimeslot_class"
android:layout_below="#+id/newtimeslot_class"
android:layout_toRightOf="#+id/imageView1"
android:background="#android:color/darker_gray" />
<TextView
android:id="#+id/newtimeslot_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/newtimeslot_class"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#646464" />
<TextView
android:id="#+id/newtimeslot_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/imageView2"
android:layout_marginRight="5dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#646464" />
<TextView
android:id="#+id/newtimeslot_comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/newtimeslot_location"
android:layout_marginBottom="10dp"
android:layout_marginRight="5dp"
android:layout_marginTop="2dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#646464" />
</RelativeLayout>
</FrameLayout>
Unfortunately though, when i run this on an android device, the line to the left completely disappears. It instead looks like
I have just done the usual in terms on inflating it, and i only ever access the TextView objects. So i'm just wondering what could possibly be going on and if someone could help me out of this mess?
Cheers
Edit: The inflation code
#Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
final View view = mInflater.inflate(R.layout.timeslotlayout_new, parent, false);
return view;
}
I suspect the reference #android:color/darker_gray to be the problem.
It might be that on some devices, this value does not exist ?!? (it may be under another name for instance)
Try setting the background attribute to a COLOR value (instead of an android color reference) like this #00000 which represents black (or choose another custom color like this #A9A9A9 for DarkGray ) :
android:background="#A9A9A9"
/OR/
Create an XML file for most basic colors like done HERE, in this manner you are sure that the colors will not change among devices, and most of all, that they will exist on all devices for your application.
So if you do so (see the link), you can create a color like this (the name of the XML file does not matter at all) :
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="Black">#000000</color>
<color name="DarkGray">#A9A9A9</color>
</resources>
And reference it in the following way :
android:background="#color/DarkGray"
Note :
No matter if this solved your issue or not, I strongly advise you to follow this manner to be on the safe side.
Maybe you're missing to set this:
android:layout_alignParentLeft="false"
to this:
android:layout_alignParentLeft="true"
And, by the way, android:orientation="vertical" doesn't apply to a relative layout. It applies only to LinearLayout.
And to the newtimeslot_time TextView change the
android:layout_toRightOf="#+id/imageView1"
to
android:layout_toRightOf="#id/imageView1"
Hope it helps!
Cheers!