自定义android控件
来源:互联网 发布:顺序循环队列c语言 编辑:程序博客网 时间:2024/06/04 22:09
package com.example.ui;import android.content.Context;import android.util.AttributeSet;import android.view.LayoutInflater;import android.view.View;import android.widget.Button;import android.widget.RelativeLayout;import android.widget.Toast;import com.example.uiwidgetcustom.R;public class HeaderLayout extends RelativeLayout { private Button btn_back; public HeaderLayout(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub LayoutInflater.from(context).inflate(R.layout.headerlayout, this); initView(); initEvent(); } public void initView(){ btn_back = (Button) findViewById(R.id.back); } public void initEvent(){ btn_back.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub Toast.makeText(getContext(), "返回",1).show(); } }); }}
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/headerlayout" android:background="#00A779" > <Button android:id="@+id/back" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="返回" android:textColor="#fff" android:background="#00A779"></Button> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:textColor="#fff" android:text="Android4高级编程" ></TextView></RelativeLayout>
然后引入:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:background="#fff" > <com.example.ui.HeaderLayout android:layout_width="match_parent" android:layout_height="wrap_content" ></com.example.ui.HeaderLayout></LinearLayout>
0 0
- [Android自定义控件] Android自定义控件
- Android自定义控件] Android自定义控件
- [Android自定义控件] Android自定义控件
- [Android自定义控件] Android自定义控件
- [Android自定义控件] Android自定义控件
- [Android自定义控件] Android自定义控件
- [Android自定义控件] Android自定义控件
- Android 自定义控件 单页翻书控件
- android虚线控件---自定义控件
- android自定义控件实例 --控件
- Android自定义控件--组合控件
- android 控件 自定义组合控件
- 【android自定义控件】ProgressBar自定义
- Android自定义控件 自定义属性
- Android自定义控件 -- 自定义View
- Android自定义控件 -- 自定义ViewGroup
- Android 自定义控件 自定义标题栏
- Android 自定义控件-自定义进度条。
- UI界面之概况
- 编写一个过程将查询的字段和where条件中的字符串值动态调用
- DeepLearning tutorial(2)机器学习算法在训练过程中保存参数
- ZeroMQ指南:第4章:可靠的请求-应答
- a different object with the same identifier value was already associated with the session异常解决办法
- 自定义android控件
- mfc 一个关于子窗口相互覆盖下的消息响应的问题
- NYOJ 633 弟弟的作业【字符串处理】
- Vmware+gdb调试Linux内核——工欲善其事,必先利其器
- 非接环境(PPSE)和接触环境(PSE)的FCI有什么区别
- String一些函数的用法
- maven jboss 插件配置
- uint8_t / uint16_t / uint32_t /uint64_t 是什么数据类型 - 大总结
- property-ref to unmapped class: com.xnjd.hynm.model.Polling