TextViewクラス

ViewクラスTextViewクラス

TextViewクラスとは?

 状態:-  閲覧数:1,564  投稿日:2013-12-18  更新日:2018-08-02  

テキストを表示するクラス


文字を表示する機能を持つ

レイアウトの子要素
・R.layout.mainが示すmain.xmlファイルなどに記述

クラス構成

 閲覧数:448 投稿日:2013-12-18 更新日:2014-03-17 

親クラス



java.lang.Object
  ↳ android.view.View
   ↳ android.widget.TextView



XML属性一覧

 閲覧数:491 投稿日:2014-03-15 更新日:2014-09-20 
XML属性一覧
要素 意味
android:drawableLeft 画像をテキストの左側に描画
android:drawableRight 画像をテキストの右側に描画
android:drawableTop 画像をテキストの上側に描画

Viewクラスより継承されたXML属性一覧
要素 意味
android:padding 上下左右のパディング
android:paddingTop 上のパディング
android:paddingBottom 下のパディング
android:paddingLeft 左のパディング
android:paddingRight 右のパディング


メソッド一覧

 閲覧数:585 投稿日:2014-03-16 更新日:2014-03-31 
setText
・文字列の変更
※引数で直接文字列指定するか、文字列のリソースIDを指定

コード例

 閲覧数:463 投稿日:2014-03-16 更新日:2014-03-31 

例1


▼/HelloAndroid/src/android/style/HelloAndroidActivity.java
package android.style;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class HelloAndroidActivity extends Activity {
   /** Called when the activity is first created. */
   @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.main);
       
       TextView tview = (TextView)findViewById(R.id.textView1);
       tview.setText("動的に設定します");
   }
}


・xml … レイアウト
▼/HelloAndroid/res/layout/main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:orientation="vertical" >

   <TextView
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:text="@string/hello" />



   <Button
       android:id="@+id/button1"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:text="@string/button_str1" />

   <TextView
       android:id="@+id/textView1"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:text="TextView" />

</LinearLayout>



コメント投稿(ログインが必要)



類似度ページランキング
順位 ページタイトル抜粋
1 TextViewクラス 91
2 Viewクラス 78
3 ListViewクラス 73
4 EditTextクラス 73
5 Timeクラス 67
6 CardViewクラス 64
7 ViewGroupクラス 61
8 ScrollViewクラス 58
9 Contextクラス 57
10 SurfaceViewクラス 56
11 Dateクラス 56
12 TableRowクラス 55
13 RecyclerViewクラス 54
14 Toastクラス 53
15 DateUtilsクラス 52
16 Threadクラス 50
17 TableLayoutクラス 48
18 AlertDialogクラス 48
19 LinearLayoutクラス 46
20 Activityクラス 45
2025/10/09 12:23 更新