最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

android自定義控件和自定義回調(diào)函數(shù)步驟示例

 更新時間:2014年01月11日 14:32:15   作者:  
這篇文章主要介紹了android自定義控件步驟示例,包括為View類增加屬性、響應(yīng)用戶消息、自定義回調(diào)函數(shù)等方法

自定義控件的步驟:

1 View的工作原理
2 編寫View類
3 為View類增加屬性
4 繪制屏幕
5 響應(yīng)用戶消息
6 自定義回調(diào)函數(shù)

java代碼

復(fù)制代碼 代碼如下:

private class MyText extends LinearLayout {
    private TextView text1;

    /*
     * private String text;
     *
     * public String getText() { return text; }
     *
     * public void setText(String text) { this.text = text; }
     */
    public MyText(Context context) {
        super(context);
        // TODO Auto-generated constructor stub
        LayoutInflater inflate = (LayoutInflater) context
                .getSystemService(context.LAYOUT_INFLATER_SERVICE);
        View view = inflate.inflate(R.layout.tabhost_item, this, true);
        text1 = (TextView) view.findViewById(R.id.tabhost_tv);
    }

    public void setTextViewText(String tabhost_name) {
        text1.setText(tabhost_name);
    }
    /*
     * @Override protected void onDraw(Canvas canvas) { // TODO
     * Auto-generated method stub super.onDraw(canvas); Paint p = new
     * Paint(); p.setColor(Color.WHITE); p.setTextSize(10);
     * canvas.drawText(text, 25, 25, p); }
     */

}

xml代碼

復(fù)制代碼 代碼如下:

<?xml version="1.0" encoding="utf-8"?>
<!-- GMapTabActivity中自定義控件MyText的自布局 -->

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

相關(guān)文章

最新評論

襄垣县| 郁南县| 无极县| 彩票| 巴青县| 鹤山市| 襄汾县| 红安县| 阿荣旗| 开化县| 廉江市| 晴隆县| 柏乡县| 梅河口市| 栾川县| 平远县| 凯里市| 绍兴县| 射阳县| 响水县| 方山县| 东阳市| 岐山县| 富顺县| 砚山县| 青川县| 安陆市| 古田县| 柳河县| 内丘县| 沈丘县| 明水县| 延川县| 天门市| 大连市| 麟游县| 武强县| 桂东县| 介休市| 廉江市| 沿河|