以下の内容はhttps://lipoyang.hatenablog.com/entry/20140613/p1より取得しました。


Androidアプリ開発メモ(4)

ActivityにViewを配置する

Javaのみで
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ...
    // Viewのインスタンスを生成 (アプリのコンテキストを参照して )
    HogeView myView = new HogeView( getApplication() );
    // 画面に配置
    setContentView(myView);
レイアウトを使用
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ...
    // レイアウトにしたがって画面に配置
    setContentView(R.layout.activity_main);
    // 必要ならレイアウトからインスタンスを取得
    HogeView myView = (HogeView)findViewById(R.id.hogeView1);

Viewの背景

Java
    myView.setBackgroundResource(R.drawable.bg);
レイアウトで
<net.lipoyang.hoge.HogeView
    android:id="@+id/hogeView1"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/bg"
/>



以上の内容はhttps://lipoyang.hatenablog.com/entry/20140613/p1より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14