Viewクラス

Viewクラス

View

 状態:-  閲覧数:1,403  投稿日:2013-12-18  更新日:2014-03-31  
画面処理(文字、画像、ボタンなど)を実施するためのクラス
・「TextView…文字を扱う」「ImageView…画像を扱う」「Button…ボタンを扱う」は、それぞれView のサブクラス

クラス構成

 閲覧数:374 投稿日:2014-02-24 更新日:2014-03-31 

親クラス



java.lang.Object
  ↳ android.view.View



XML属性一覧

 閲覧数:363 投稿日:2014-02-25 更新日:2014-03-31 
XML属性一覧
要素 意味
android:padding 上下左右のパディング
android:paddingTop 上のパディング
android:paddingBottom 下のパディング
android:paddingLeft 左のパディング
android:paddingRight 右のパディング


メソッド一覧

 閲覧数:1,041 投稿日:2014-02-26 更新日:2014-03-31 

setOnClickListener


引数の型
・View.OnClickListener


onDraw


主な利用用途
・描画処理

引数の型
・Canvasクラス
引数内容
・オブジェクト
※Canvasオブジェクトとは、いわゆるグラフィックコンテキストのこと。描画のためのメソッドが多数用意されている

コード例

 閲覧数:381 投稿日:2014-02-26 更新日:2014-03-31 

例1


HelloAndroid
・ビューを使って、文字を表示

▼/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 … レイアウト
▼/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>



Viewクラスそれぞれの特徴。Viewクラスが多過ぎるので特徴を整理

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



類似度ページランキング
順位 ページタイトル抜粋
1 Viewクラス 100
2 ListViewクラス 78
3 TextViewクラス 78
4 CardViewクラス 78
5 ViewGroupクラス 74
6 Timeクラス 71
7 ScrollViewクラス 70
8 SurfaceViewクラス 67
9 RecyclerViewクラス 64
10 Dateクラス 57
11 TableRowクラス 56
12 EditTextクラス 56
13 Rクラス 55
14 DateUtilsクラス 53
15 抽象クラス 50
16 Bundleクラス 50
17 Threadクラス 50
18 AlertDialogクラス 48
19 Contextクラス 47
20 Logクラス 46
2024/9/21 20:37 更新