博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Android - 自定义标题栏
阅读量:4180 次
发布时间:2019-05-26

本文共 927 字,大约阅读时间需要 3 分钟。

layout文件title.xml

java文件 TitleLayout

package com.example.constrain;import android.app.Activity;import android.content.Context;import android.util.AttributeSet;import android.view.LayoutInflater;import android.view.View;import android.widget.Button;import android.widget.LinearLayout;import androidx.annotation.Nullable;import androidx.core.view.LayoutInflaterFactory;import java.text.AttributedCharacterIterator;public class TitleLayout extends LinearLayout {    public TitleLayout(Context context, AttributeSet attrs) {        super(context, attrs);        LayoutInflater.from(context).inflate(R.layout.title, this);        Button button1 = (Button)findViewById(R.id.button1);        button1.setOnClickListener(new OnClickListener() {            @Override            public void onClick(View v) {                ((Activity)getContext()).finish();            }        });    }}

 

引用title的activity

 

转载地址:http://fwmai.baihongyu.com/

你可能感兴趣的文章
HTML5学习之——HTML 5 应用程序缓存
查看>>
HTML5学习之——HTML5 内联 SVG
查看>>
HTML5学习之——HTML 5 服务器发送事件
查看>>
SVG学习之——HTML 页面中的 SVG
查看>>
SVG 形状学习之——SVG圆形
查看>>
SVG 滤镜学习之——SVG 滤镜
查看>>
mysql中用命令行复制表结构的方法
查看>>
hbase shell出现ERROR: org.apache.hadoop.hbase.ipc.ServerNotRunningYetException
查看>>
让代码变得更优雅-Lombok
查看>>
解决Rhythmbox乱码
查看>>
豆瓣爱问共享资料插件发布啦
查看>>
kermit的安装和配置
查看>>
vim 配置
查看>>
openocd zylin
查看>>
进程创建时文件系统处理
查看>>
内核线程创建
查看>>
linux中cat命令使用详解
查看>>
java中的异常机制
查看>>
商务智能-基本方法-数据钻取
查看>>
C++程序员技术需求规划(发展方向)
查看>>