Last active
September 19, 2015 12:59
-
-
Save Pornpun/12e2793dc99b30bfd32d to your computer and use it in GitHub Desktop.
TestApp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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" | |
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"> | |
<TextView | |
android:id="@+id/tv_text" | |
android:text="@string/hello_world" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:background="#ffff2455"/> | |
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mystou.testapp; | |
import android.graphics.Color; | |
import android.os.Bundle; | |
import android.support.v7.app.ActionBarActivity; | |
import android.widget.TextView; | |
public class MainActivity extends ActionBarActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
// ประกาศตัวแปรประเภท TextView | |
TextView textView; | |
// กำหนดค่าให้ตัวแปร = id tv_text | |
textView = (TextView) findViewById(R.id.tv_text); | |
// เปลียนข้อความ textView เป็น สวัสดี | |
textView.setText("สวัสดี"); | |
// เปลียนสีพื้นหลังเป็นสีเขียว | |
textView.setBackgroundColor(Color.GREEN); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment