Experiment 4 use of color, string resources

Source: Internet
Author: User

Course Name

Mobile Internet development based on Android platform

Date of experiment

March 24, 2016

Name of the experimental project

Use of color, string resources

Location of the experiment

S3010

Type of experiment

-Verification Type √ design type-comprehensive type

Hours

4

The purpose and requirements of the experiment (the knowledge points which are involved in this experiment and are required to be mastered)

Purpose

    1. Learn how to use color and string resources in Android.
    2. Understand how size and layout resources are used in Android.

Requirements

    1. Use color resources for activity and view in project;
    2. Use string resources and understand the reference mechanism of string resources;
    3. Set the dimensions for the view components in Android;
    4. Use layout resources to place components on the interface at the specified location.

second, the experimental environment (the hardware equipment and related software used in this experiment)

(1) PC Machine

(2) Operating system: Windows XP

(3) Software: Eclipse, jdk1.6,android Sdk,adt

Third, the contents and steps of the experiment

Process

1. Create a project

2. Modifying string resources

Open the/res/values/strings.xml file.

Click the Add button to add a string, enter the string name and value

A new project contains three existing strings

3. New color resource color.xml

4. using resource colors and string resources

Four, the experimental results (the experimental source program list and operating results or experimental conclusions, experimental design drawings)

1234567891011121314151617181920 <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:paddingBottom="@dimen/activity_vertical_margin"    android:paddingLeft="@dimen/activity_horizontal_margin"    android:paddingRight="@dimen/activity_horizontal_margin"    android:paddingTop="@dimen/activity_vertical_margin"    android:background="#00ffff"    tools:context=".MainActivity">    <TextView        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:text="@string/hello_world"        android:gravity="center"        android:textSize="20sp"        android:textColor="@color/text_blue"/></RelativeLayout>

  

2. Resources

12345678910111213141516171819202122232425262728293031 <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:paddingBottom="@dimen/activity_vertical_margin"    android:paddingLeft="@dimen/activity_horizontal_margin"    android:paddingRight="@dimen/activity_horizontal_margin"    android:paddingTop="@dimen/activity_vertical_margin"    android:background="@drawable/ic_launcher"    tools:context=".MainActivity">    <TextView        android:id="@+id/textView1"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_alignParentTop="true"        android:layout_centerHorizontal="true"        android:textSize="30sp"        android:layout_marginTop="15dp"        android:text="@string/gzcc"/>    <Button        android:id="@+id/but1"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_below="@+id/textView1"        android:layout_centerHorizontal="true"        android:layout_marginTop="22dp"        android:text="@string/find"/> </RelativeLayout>

  

1234567891011121314151617181920212223242526272829 packagecom.example.ziyuan;importandroid.os.Bundle;importandroid.app.Activity;importandroid.view.Menu;importandroid.view.View;import android.view.View.OnClickListener;importandroid.widget.Button;importandroid.widget.TextView;publicclassMainActivity extendsActivity {    TextView tv;    @Override    protectedvoidonCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        Button btn = (Button)findViewById(R.id.but1);        btn.setOnClickListener(newOnClickListener() {                        @Override            publicvoidonClick(View arg0) {                // TODO Auto-generated method stub                 tv=(TextView)findViewById(R.id.textView1);                tv.setTextColor(TRIM_MEMORY_MODERATE);            }        });    }

  

Five, Experimental summary (analysis of the results of the experiment, experience and improvement of experimental ideas)

After this experiment, you can learn more about the use of Android experiment color, string resources, but the specific structure of Android still do not understand, in the future need to see more, more practice.

Experimental reviews

Experimental results

Guide Teacher Signature: Date

Experiment 4 use of color, string resources

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.