Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Standard ListViews: updating the main layout
- //Email, twitter, facebook, yik yak all display data in some kind of a list. Sometimes its text, sometimes its images, etc
- // List is so commonly used that we really wanna understand it in detail!
- // The basic idea is that we have some list of data stored as an array of collection of objects.
- // We create a view, a layout file of how we want it to be displayed.
- // And then we use an adaptor(a special JAVA class) to prepare the data and adapt it for display.
- <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"
- android:paddingLeft="@dimen/activity_horizontal_margin"
- android:paddingRight="@dimen/activity_horizontal_margin"
- android:paddingTop="@dimen/activity_vertical_margin"
- <!-- got rid of default android:paddingBottom to put the buttons all the way at the bottom-->
- tools:context=".MainActivity"
- android:background="#FFFC970b">
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="--"
- android:id="@+id/temperatureLabel"
- android:layout_centerVertical="true"
- android:layout_centerHorizontal="true"
- android:textColor="@android:color/white"
- android:textSize="150sp"/>
- <ImageView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:id="@+id/degreeImageView"
- android:layout_alignTop="@+id/temperatureLabel"
- android:layout_toRightOf="@+id/temperatureLabel"
- android:layout_toEndOf="@+id/temperatureLabel"
- android:src="@drawable/degree"
- android:layout_marginTop="50dp"/>
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="..."
- android:id="@+id/timeLabel"
- android:layout_above="@+id/degreeImageView"
- android:layout_centerHorizontal="true"
- android:textColor="#80ffffff"
- android:textSize="18sp"/>
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Alcatraz Island, CA"
- android:id="@+id/locationLabel"
- android:layout_above="@+id/timeLabel"
- android:layout_centerHorizontal="true"
- android:layout_marginBottom="60dp"
- android:textColor="@android:color/white"
- android:textSize="24sp"/>
- <ImageView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:id="@+id/iconImageView"
- android:layout_alignBottom="@+id/locationLabel"
- android:layout_alignParentLeft="true"
- android:layout_alignParentStart="true"
- android:src="@drawable/cloudy_night"/>
- <LinearLayout
- android:orientation="horizontal"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_below="@+id/temperatureLabel"
- android:layout_centerHorizontal="true"
- android:layout_marginTop="10dp"
- android:weightSum="100"
- android:id="@+id/linearLayout">
- <LinearLayout
- android:orientation="vertical"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_weight="50">
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="HUMIDITY"
- android:id="@+id/humidityLabel"
- android:textColor="#80FFFFFF"
- android:gravity="center_horizontal"/>
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="--"
- android:id="@+id/humidityValue"
- android:textColor="@android:color/white"
- android:textSize="24sp"
- android:gravity="center_horizontal"/>
- </LinearLayout>
- <LinearLayout
- android:orientation="vertical"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_weight="50">
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="RAIN/SNOW?"
- android:id="@+id/precipLabel"
- android:textColor="#80ffffff"
- android:gravity="center_horizontal"/>
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="--"
- android:id="@+id/precipValue"
- android:textColor="@android:color/white"
- android:textSize="24sp"
- android:gravity="center_horizontal"/>
- </LinearLayout>
- </LinearLayout>
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Getting current weather..."
- android:id="@+id/summaryLabel"
- android:layout_below="@+id/linearLayout"
- android:layout_centerHorizontal="true"
- android:layout_margin="40dp"
- android:textColor="@android:color/white"
- android:textSize="18sp"
- android:gravity="center_horizontal"/>
- <ImageView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:id="@+id/refreshImageView"
- android:layout_alignParentTop="true"
- android:layout_centerHorizontal="true"
- android:src="@drawable/refresh"/>
- <ProgressBar
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:id="@+id/progressBar"
- android:layout_alignParentTop="true"
- android:layout_centerHorizontal="true"
- android:layout_alignBottom="@+id/refreshImageView"/>
- <LinearLayout
- android:orientation="horizontal"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentBottom="true"
- android:layout_alignParentLeft="true"
- android:layout_alignParentStart="true">
- // add two buttons to the bottom
- <Button
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="HOURLY"
- android:id="@+id/hourlyButton"
- android:layout_weight="1"
- android:background="#40ffffff"
- android:textColor="#ffffffff"/>
- <Button
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="7 DAY"
- android:id="@+id/dailyButton"
- android:layout_weight="1"
- android:background="#40ffffff"
- android:textColor="#ffffffff"/>
- </LinearLayout>
- </RelativeLayout>
- // https://teamtreehouse.com/library/android-lists-and-adapters/standard-listviews/updating-the-main-layout
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement